summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmark/encoder.rb8
-rw-r--r--ext/json/generator/generator.c2
2 files changed, 4 insertions, 6 deletions
diff --git a/benchmark/encoder.rb b/benchmark/encoder.rb
index bd0105ae38..2b02d5d5e9 100644
--- a/benchmark/encoder.rb
+++ b/benchmark/encoder.rb
@@ -59,11 +59,9 @@ end
benchmark_encoding "small nested array", [[1,2,3,4,5]]*10
benchmark_encoding "small hash", { "username" => "jhawthorn", "id" => 123, "event" => "wrote json serializer" }
-# On this one we're a bit slower (~25%).
-benchmark_encoding "mostly utf8", ([("€" * 3333)] * 2000), except: %i(json_state)
-
-# On these three benchmarks we perform well. Either on par or very closely faster/slower
-benchmark_encoding "mixed utf8", ([("a" * 5000) + "€" + ("a" * 5000)] * 2000), except: %i(json_state)
+# On these benchmarks we perform well. Either on par or very closely faster/slower
+benchmark_encoding "mixed utf8", ([("a" * 5000) + "€" + ("a" * 5000)] * 500), except: %i(json_state)
+benchmark_encoding "mostly utf8", ([("€" * 3333)] * 500), except: %i(json_state)
benchmark_encoding "twitter.json", JSON.load_file("#{__dir__}/data/twitter.json"), except: %i(json_state)
benchmark_encoding "citm_catalog.json", JSON.load_file("#{__dir__}/data/citm_catalog.json"), except: %i(json_state)
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index f784e3b4b2..6e79bf4a1a 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -71,7 +71,7 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE str, const char esca
}
case 3: {
unsigned char b2 = ptr[pos + 1];
- if (out_script_safe && b2 == 0x80) {
+ if (RB_UNLIKELY(out_script_safe && b2 == 0x80)) {
unsigned char b3 = ptr[pos + 2];
if (b3 == 0xA8) {
FLUSH_POS(3);