Skip to content

Instantly share code, notes, and snippets.

@arielm
arielm / std::map key copy test
Last active January 3, 2016 04:49
Checking how many copies are taking place when using complex keys for maps: 1. The keys are created once, and then copied when inserted into the map. 2. The keys are not copied when std::map::find is invoked (unlike, apparently, when using Boost.bimap...)
#include <string>
#include <tuple>
#include <iostream>
struct TestObject
{
std::string s;
int i;
TestObject(const std::string &s, int i)
@arielm
arielm / Boost.bimap key copying test
Created January 14, 2014 10:54
I'm using Boost.bimap for implementing a LRU cache with some "complex key" containing a string. The problem is that the key is copied every-time I'm invoking find(). I would like to avoid this un-necessary copy (and in general: make as few as possible copies of the string, maybe via templates?)
#include <string>
#include <iostream>
#include <boost/bimap.hpp>
#include <boost/bimap/list_of.hpp>
#include <boost/bimap/set_of.hpp>
class Test
{
public:
LOCAL_PATH := $(call my-dir)/..
include $(CLEAR_VARS)
ICU_COMMON_SRC = common
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(ICU_COMMON_SRC)
LOCAL_SRC_FILES += $(ICU_COMMON_SRC)/cmemory.c
LOCAL_SRC_FILES += $(ICU_COMMON_SRC)/cstring.c
LOCAL_SRC_FILES += $(ICU_COMMON_SRC)/cwchar.c
@arielm
arielm / shared_ptr iteration.cpp
Created February 5, 2014 11:06
Avoiding un-necessary shared_ptr copy when iterating over a container. Paste code into http://www.compileonline.com/compile_cpp11_online.php for testing.
#include <iostream>
#include <string>
#include <vector>
#include <memory>
using namespace std;
int main()
{
vector<shared_ptr<string>> strings;
@arielm
arielm / Android.mk
Created January 29, 2015 21:59
The path for this file should be: mozjs-31.2.0/prebuilt/spidermonkey/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifndef SPIDERMONKEY_SDK_PATH
SPIDERMONKEY_SDK_PATH := $(LOCAL_PATH)/../../..
endif
ifndef SPIDERMONKEY_DIST_PATH
SPIDERMONKEY_DIST_PATH := $(SPIDERMONKEY_SDK_PATH)/js/src/build-android/dist
endif
@arielm
arielm / build.sh
Created January 29, 2015 22:03
The path for this file should be: mozjs-31.2.0/js/src/build-android
#!/bin/sh
if [ -z $NDK_ROOT ]; then
echo "NDK_ROOT MUST BE DEFINED!"
echo "e.g. export NDK_ROOT=$HOME/android-ndk"
exit -1
fi
host_kernel=$(uname -s | tr "[:upper:]" "[:lower:]")
host_arch=$(uname -m)
@arielm
arielm / build_debug.sh
Created January 29, 2015 22:08
The path for this file should be: mozjs-31.2.0/js/src/build-osx
#!/bin/sh
cpus=$(sysctl hw.ncpu | awk '{print $2}')
../configure --disable-tests --disable-shared-js --enable-llvm-hacks \
--without-intl-api \
--disable-threadsafe \
--enable-exact-rooting --enable-gcgenerational \
--enable-gczeal --enable-root-analysis \
--enable-debug --enable-debug-symbols \
@arielm
arielm / build.sh
Last active February 18, 2019 05:36
TESTING EMSCRIPTEN WITH C++11 AND BOOST
# BUILDING BOOST FOR EMSCRIPTEN...
# REFERENCE: http://www.boost.org/doc/libs/1_58_0/more/getting_started/unix-variants.html
# TESTED WITH: BOOST 1.53 ON OSX 10.10
# DEPENDS ON: MODIFIED user-config.jam
# REQUIRED FOR iostreams
# REFERENCE: http://www.boost.org/doc/libs/1_58_0/libs/iostreams/doc/installation.html#bjam
cd $EMSCRIPTEN_PATH; ./embuilder.py build zlib
export NO_BZIP2=1
/*
* REFERENCE: https://github.com/arielm/chronotext-boost/wiki/Basic-code-sample
*/
#include <iostream>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
@arielm
arielm / anisotropy.cpp
Created September 29, 2015 20:19
Emscripten minimal test-case for showcasing issue with anisotropic filtering
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <stdio.h>
#include <emscripten.h>
#include <emscripten/html5.h>
int main()
{
emscripten_set_canvas_size(256, 256);