File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -238,7 +238,11 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
238238 task :release => :build
239239else
240240 desc "Compiling extension"
241- task :compile => [ EXT_PARSER_DL , EXT_GENERATOR_DL ]
241+ if RUBY_ENGINE == 'truffleruby'
242+ task :compile => [ EXT_PARSER_DL ]
243+ else
244+ task :compile => [ EXT_PARSER_DL , EXT_GENERATOR_DL ]
245+ end
242246
243247 file EXT_PARSER_DL => EXT_PARSER_SRC do
244248 cd EXT_PARSER_DIR do
Original file line number Diff line number Diff line change 11require 'mkmf'
22
3- $defs << "-DJSON_GENERATOR"
4- create_makefile 'json/ext/generator'
3+ if RUBY_ENGINE == 'truffleruby'
4+ # The pure-Ruby generator is faster on TruffleRuby, so skip compiling the generator extension
5+ File . write ( 'Makefile' , dummy_makefile ( "" ) . join )
6+ else
7+ $defs << "-DJSON_GENERATOR"
8+ create_makefile 'json/ext/generator'
9+ end
Original file line number Diff line number Diff line change @@ -4,11 +4,19 @@ module JSON
44 # This module holds all the modules/classes that implement JSON's
55 # functionality as C extensions.
66 module Ext
7- require 'json/ext/parser'
8- require 'json/ext/generator'
9- $DEBUG and warn "Using Ext extension for JSON."
10- JSON . parser = Parser
11- JSON . generator = Generator
7+ if RUBY_ENGINE == 'truffleruby'
8+ require 'json/ext/parser'
9+ require 'json/pure'
10+ $DEBUG and warn "Using Ext extension for JSON parser and Pure library for JSON generator."
11+ JSON . parser = Parser
12+ JSON . generator = JSON ::Pure ::Generator
13+ else
14+ require 'json/ext/parser'
15+ require 'json/ext/generator'
16+ $DEBUG and warn "Using Ext extension for JSON."
17+ JSON . parser = Parser
18+ JSON . generator = Generator
19+ end
1220 end
1321
1422 JSON_LOADED = true unless defined? ( ::JSON ::JSON_LOADED )
You can’t perform that action at this time.
0 commit comments