diff --git a/scripts/benchmarks.clj b/scripts/benchmarks.clj index 30b95bd..e34fada 100644 --- a/scripts/benchmarks.clj +++ b/scripts/benchmarks.clj @@ -165,7 +165,7 @@ (let [data [1 2 3 4 5 6 7 8 9 10]] - (run-benchmark "first value of a vector" 10000000 + (run-benchmark "first value of a size 10 vector" 10000000 (first data) (select-any ALL data) (select-any FIRST data) diff --git a/src/clj/com/rpl/specter.cljc b/src/clj/com/rpl/specter.cljc index 84ce781..b2f9f4c 100644 --- a/src/clj/com/rpl/specter.cljc +++ b/src/clj/com/rpl/specter.cljc @@ -738,8 +738,10 @@ (let [newe (next-fn NONE)] (if (identical? NONE newe) structure - (conj structure newe) - )))) + (if (nil? structure) + #{newe} + (conj structure newe) + ))))) (defnav ^{:doc "Navigate to 'void' element before the sequence. diff --git a/test/com/rpl/specter/core_test.cljc b/test/com/rpl/specter/core_test.cljc index ff86cf4..ef36996 100644 --- a/test/com/rpl/specter/core_test.cljc +++ b/test/com/rpl/specter/core_test.cljc @@ -1441,6 +1441,7 @@ (is (predand= list? '(3 1 2) (setval s/BEFORE-ELEM 3 '(1 2)))) (is (predand= list? '(1) (setval s/BEFORE-ELEM 1 nil))) (is (= #{1 2 3} (setval s/NONE-ELEM 3 #{1 2}))) + (is (= #{1} (setval s/NONE-ELEM 1 nil))) ) (deftest subvec-test