Browse Source

Add macro to enable HiPE

Takeru Ohta 9 years ago
parent
commit
85c664484d
3 changed files with 19 additions and 3 deletions
  1. 11 3
      README.md
  2. 4 0
      src/jsone_decode.erl
  3. 4 0
      src/jsone_encode.erl

+ 11 - 3
README.md

@@ -28,9 +28,6 @@ QuickStart
 $ git clone git://github.com/sile/jsone.git
 $ cd jsone
 
-# If you want to use HiPE enabled version, please execute following command.
-# $ git checkout hipe
-
 # compile
 $ make compile
 
@@ -46,6 +43,17 @@ $ make start
 [1,2,3]
 ```
 
+Enable HiPE
+-----------
+
+If you want to use HiPE compiled version, please add following code to your rebar.config.
+
+```erlang
+{overrides,
+  [
+    {add, jsone, [{erl_opts, [{d, 'ENABLE_HIPE'}]}]}
+  ]}.
+```
 
 Usage Example
 -------------

+ 4 - 0
src/jsone_decode.erl

@@ -27,6 +27,10 @@
 %%%---------------------------------------------------------------------------------------
 -module(jsone_decode).
 
+-ifdef(ENABLE_HIPE).
+-compile([native, {hipe, [o3]}]).
+-endif.
+
 %%--------------------------------------------------------------------------------
 %% Exported API
 %%--------------------------------------------------------------------------------

+ 4 - 0
src/jsone_encode.erl

@@ -27,6 +27,10 @@
 %%%---------------------------------------------------------------------------------------
 -module(jsone_encode).
 
+-ifdef(ENABLE_HIPE).
+-compile([native, {hipe, [o3]}]).
+-endif.
+
 %%--------------------------------------------------------------------------------
 %% Exported API
 %%--------------------------------------------------------------------------------