Skip to content

Commit

Permalink
skip some allocs in "cond" generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenet committed Nov 3, 2016
1 parent 5dd07d4 commit 6d451ee
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/clj/qbits/hayt/cql.clj
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@

(defrecord CQLFn [name args]
CQLEntities
(cql-identifier [{fn-name :name args :args}]
(cql-identifier [this]
(str (clojure.core/name name)
(cql-identifiers-join-comma+parens args)))
(cql-value [{fn-name :name args :args}]
(cql-value [this]
(str (clojure.core/name name)
(cql-values-join-comma+parens args))))

Expand Down Expand Up @@ -261,17 +261,20 @@

;; secondary index clauses helpers
(defn query-cond-sequential-entry [op column value]
(let [[column value] (if (sequential? column)
[(CQLComposite. column)
(CQLComposite. value)]
[column value])
(let [composite? (sequential? column)
column (if composite?
(CQLComposite. column)
column)
value (if composite?
(CQLComposite. value)
value)
col-name (cql-identifier column)]
(if (identical? :in op)
(str* col-name
" IN "
(if (sequential-or-set? value)
(cql-values-join-comma+parens value)
(cql-value value)))
(case op
:in (str* col-name
" IN "
(if (sequential-or-set? value)
(cql-values-join-comma+parens value)
(cql-value value)))
(str* col-name
" " (operators op) " "
(cql-value value)))))
Expand Down

0 comments on commit 6d451ee

Please sign in to comment.