Browse Source

[ruby/sinatra] Don't use `JSON.fast_generate` (#9521)

It's not faster for small payloads.

+--------------------+------+-----+-----+-------+--------------+
|         branch_name|update|   db|query|fortune|weighted_score|
+--------------------+------+-----+-----+-------+--------------+
|              master|  8301|36433|15826|  28025|          1089|
|remove-fast-generate|  8897|38895|16317|  27660|          1143|
+--------------------+------+-----+-----+-------+--------------+
Petrik de Heus 7 months ago
parent
commit
82b2fc4d6f

+ 1 - 1
frameworks/Ruby/sinatra-sequel/Gemfile.lock

@@ -4,7 +4,7 @@ GEM
     base64 (0.2.0)
     bigdecimal (3.1.8)
     iodine (0.7.58)
-    json (2.8.2)
+    json (2.9.1)
     kgio (2.11.4)
     mustermann (3.0.3)
       ruby2_keywords (~> 0.0.1)

+ 1 - 1
frameworks/Ruby/sinatra-sequel/hello_world.rb

@@ -22,7 +22,7 @@ class HelloWorld < Sinatra::Base
 
     def json(data)
       content_type :json
-      JSON.fast_generate(data)
+      data.to_json
     end
 
     # Return a random number between 1 and MAX_PK

+ 1 - 1
frameworks/Ruby/sinatra/hello_world.rb

@@ -22,7 +22,7 @@ class HelloWorld < Sinatra::Base
 
     def json(data)
       content_type :json
-      JSON.fast_generate(data)
+      data.to_json
     end
 
     # Return a random number between 1 and MAX_PK