(empty? x)
essentially means (not (seq x))
, and calling seq
may be costly. If you are certain that edge2check
is always, for instance, a vector, then you would replace that (empty? edge2check)
with (zero? (count edge2check))
. Or, at a lower level, (.isEmpty ^java.util.List edge2check)
. But given that you call rest
on it, it ceases to be a vector after recur
, so you would have to use subvec
instead of rest
. Alternatively, you could invert the order of the elements in that vector and use peek
and pop
instead of first
and rest
, respectively.
类似于 contains?
的情况 - 如果你知道 bisect
总是个持久集合,你可以用 (.contains ^clojure.lang.IPersistentSet bisect x)
代替 (contains? bisect x)
。