cemerick / friend

An extensible authentication and authorization library for Clojure Ring web applications and services.
1.16k stars 122 forks source link

Minor code improvement for the `gets` function #159

Open beoliver opened 5 years ago

beoliver commented 5 years ago

https://github.com/cemerick/friend/blob/12c5b6636430edec52c27d3f95c1ed9c6e7a1dd4/src/cemerick/friend/util.clj#L4

not really that important but the implementation of gets could be cleaner. would make more sense to be implemented as

(defn gets
  "Returns the first value mapped to key found in the provided maps."
  [k & maps]
  (->> (map #(get % k) maps)
       (remove nil?)
       first))

As you are mapping and filtering nil will never be returned meaning that the threading will continue (= (list) (some->> (map identity []))). If get is used then the call to first will either be a value or nil.