]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "hash-sets,hashtables: improved key@ word"
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 6 Oct 2016 18:18:35 +0000 (11:18 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 6 Oct 2016 18:18:35 +0000 (11:18 -0700)
This reverts commit 70c7f9e02910746918cc16bf588ef543fda80790.

core/hash-sets/hash-sets-tests.factor
core/hash-sets/hash-sets.factor
core/hashtables/hashtables.factor

index 3bf7f8a45435945ef48ccc53ccde4132dffd31f4..46dc06849fb1dfc5d6f3fa965df50333566e06a1 100644 (file)
@@ -1,17 +1,7 @@
 ! Copyright (C) 2010 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays fry hash-sets hash-sets.private kernel math
-prettyprint sequences sets sorting tools.test ;
-FROM: hashtables.private => tombstone ;
-
-! key@
-{
-    { { T{ tombstone } T{ tombstone } } f f }
-    { { T{ tombstone } 123 } 1 t }
-} [
-    "hi" 0 <hash-set> key@ 3array
-    123 HS{ 123 } key@ 3array
-] unit-test
+USING: accessors fry hash-sets kernel math prettyprint sequences
+sets sorting tools.test ;
 
 { { 1 2 3 } } [ HS{ 1 2 3 } members natural-sort ] unit-test
 
index 6bbd327371b56edd4a523cf8de16efbe932f0ef9..bfafe4ee3980889be905f5769503322161dd571e 100644 (file)
@@ -35,7 +35,8 @@ TUPLE: hash-set
     ] if ; inline recursive
 
 : key@ ( key hash -- array n ? )
-    array>> 2dup hash@ 0 (key@) ; inline
+    array>> dup length>> 0 eq?
+    [ no-key ] [ 2dup hash@ 0 (key@) ] if ; inline
 
 : <hash-array> ( n -- array )
     3 * 1 + 2/ next-power-of-2 +empty+ <array> ; inline
index 6e2903d8ee295581d1fcb430494c880d1cc5aeb3..33d0c3ace93c37964e5d6666d55da1092b3edf1b 100644 (file)
@@ -38,7 +38,8 @@ TUPLE: hashtable
     ] if ; inline recursive
 
 : key@ ( key hash -- array n ? )
-    array>> 2dup hash@ 0 (key@) ; inline
+    array>> dup length>> 0 eq?
+    [ no-key ] [ 2dup hash@ 0 (key@) ] if ; inline
 
 : <hash-array> ( n -- array )
     3 * 1 + 2/ next-power-of-2 2 * +empty+ <array> ; inline