PERF: speedup DeserializerCache (#37)

PERF: speedup DeserializerCache (#37)

Array keys are somewhat slower than string keys. Coerce keys to strings.

#               join 5:  1102518.0 i/s
#              array 5:   351877.1 i/s - 3.13x  (± 0.00) slower
#
diff --git a/lib/mini_sql/mysql/deserializer_cache.rb b/lib/mini_sql/mysql/deserializer_cache.rb
index cad2fda..53a2045 100644
--- a/lib/mini_sql/mysql/deserializer_cache.rb
+++ b/lib/mini_sql/mysql/deserializer_cache.rb
@@ -12,7 +12,7 @@ module MiniSql
       end
 
       def materialize(result, decorator_module = nil)
-        key = result.fields
+        key = result.fields.join(',')
 
         # trivial fast LRU implementation
         materializer = @cache.delete(key)
diff --git a/lib/mini_sql/postgres/deserializer_cache.rb b/lib/mini_sql/postgres/deserializer_cache.rb
index ef9bc34..99db7fe 100644
--- a/lib/mini_sql/postgres/deserializer_cache.rb
+++ b/lib/mini_sql/postgres/deserializer_cache.rb
@@ -12,7 +12,7 @@ module MiniSql
       end
 
       def materializer(result)
-        key = result.fields
+        key = result.fields.join(',')
 
         materializer = @cache.delete(key)
         if materializer
@@ -28,7 +28,7 @@ module MiniSql
       def materialize(result, decorator_module = nil)
         return [] if result.ntuples == 0
 
-        key = result.fields
+        key = result.fields.join(',')
 
         # trivial fast LRU implementation
         materializer = @cache.delete(key)
diff --git a/lib/mini_sql/postgres_jdbc/deserializer_cache.rb b/lib/mini_sql/postgres_jdbc/deserializer_cache.rb
index e022fe1..600bdea 100644
--- a/lib/mini_sql/postgres_jdbc/deserializer_cache.rb
+++ b/lib/mini_sql/postgres_jdbc/deserializer_cache.rb
@@ -15,7 +15,7 @@ module MiniSql
 
         return [] if result.ntuples == 0
 
-        key = result.fields
+        key = result.fields.join(',')
 
         # trivial fast LRU implementation
         materializer = @cache.delete(key)
diff --git a/lib/mini_sql/sqlite/deserializer_cache.rb b/lib/mini_sql/sqlite/deserializer_cache.rb
index e4051ce..75c5b97 100644
--- a/lib/mini_sql/sqlite/deserializer_cache.rb
+++ b/lib/mini_sql/sqlite/deserializer_cache.rb
@@ -13,7 +13,7 @@ module MiniSql
 
       def materialize(result, decorator_module = nil)
 
-        key = result.columns
+        key = result.columns.join(',')
 
         # trivial fast LRU implementation
         materializer = @cache.delete(key)

GitHub sha: 508a6513

This commit appears in #37 which was merged by SamSaffron.