Merge pull request #223 from crinklywrappr/from-db-object-perf
use transients to improve `from-db-object` performance
This commit is contained in:
commit
74a13a3489
1 changed files with 14 additions and 14 deletions
|
|
@ -110,26 +110,25 @@
|
||||||
|
|
||||||
(extend-protocol ConvertFromDBObject
|
(extend-protocol ConvertFromDBObject
|
||||||
nil
|
nil
|
||||||
(from-db-object [input keywordize] input)
|
(from-db-object [_ _] nil)
|
||||||
|
|
||||||
Object
|
Object
|
||||||
(from-db-object [input keywordize] input)
|
(from-db-object [input _] input)
|
||||||
|
|
||||||
Decimal128
|
Decimal128
|
||||||
(from-db-object [^Decimal128 input keywordize]
|
(from-db-object [^Decimal128 input _]
|
||||||
(.bigDecimalValue input)
|
(.bigDecimalValue input))
|
||||||
)
|
|
||||||
|
|
||||||
List
|
List
|
||||||
(from-db-object [^List input keywordize]
|
(from-db-object [^List input keywordize]
|
||||||
(vec (map #(from-db-object % keywordize) input)))
|
(mapv #(from-db-object % keywordize) input))
|
||||||
|
|
||||||
BasicDBList
|
BasicDBList
|
||||||
(from-db-object [^BasicDBList input keywordize]
|
(from-db-object [^BasicDBList input keywordize]
|
||||||
(vec (map #(from-db-object % keywordize) input)))
|
(mapv #(from-db-object % keywordize) input))
|
||||||
|
|
||||||
com.mongodb.DBRef
|
com.mongodb.DBRef
|
||||||
(from-db-object [^com.mongodb.DBRef input keywordize]
|
(from-db-object [^com.mongodb.DBRef input _]
|
||||||
input)
|
input)
|
||||||
|
|
||||||
DBObject
|
DBObject
|
||||||
|
|
@ -137,12 +136,13 @@
|
||||||
;; DBObject provides .toMap, but the implementation in
|
;; DBObject provides .toMap, but the implementation in
|
||||||
;; subclass GridFSFile unhelpfully throws
|
;; subclass GridFSFile unhelpfully throws
|
||||||
;; UnsupportedOperationException.
|
;; UnsupportedOperationException.
|
||||||
(reduce (if keywordize
|
(persistent!
|
||||||
(fn [m ^String k]
|
(reduce (if keywordize
|
||||||
(assoc m (keyword k) (from-db-object (.get input k) true)))
|
(fn [m ^String k]
|
||||||
(fn [m ^String k]
|
(assoc! m (keyword k) (from-db-object (.get input k) true)))
|
||||||
(assoc m k (from-db-object (.get input k) false))))
|
(fn [m ^String k]
|
||||||
{} (.keySet input))))
|
(assoc! m k (from-db-object (.get input k) false))))
|
||||||
|
(transient {}) (.keySet input)))))
|
||||||
|
|
||||||
|
|
||||||
(defprotocol ConvertToObjectId
|
(defprotocol ConvertToObjectId
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue