From db46b16d1055ee21a9d206a0b611c7fd036ba0db Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 6 Oct 2016 11:18:35 -0700 Subject: [PATCH] Revert "hash-sets,hashtables: improved key@ word" This reverts commit 70c7f9e02910746918cc16bf588ef543fda80790. --- core/hash-sets/hash-sets-tests.factor | 14 ++------------ core/hash-sets/hash-sets.factor | 3 ++- core/hashtables/hashtables.factor | 3 ++- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/core/hash-sets/hash-sets-tests.factor b/core/hash-sets/hash-sets-tests.factor index 3bf7f8a454..46dc06849f 100644 --- a/core/hash-sets/hash-sets-tests.factor +++ b/core/hash-sets/hash-sets-tests.factor @@ -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 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 diff --git a/core/hash-sets/hash-sets.factor b/core/hash-sets/hash-sets.factor index 6bbd327371..bfafe4ee39 100644 --- a/core/hash-sets/hash-sets.factor +++ b/core/hash-sets/hash-sets.factor @@ -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 : ( n -- array ) 3 * 1 + 2/ next-power-of-2 +empty+ ; inline diff --git a/core/hashtables/hashtables.factor b/core/hashtables/hashtables.factor index 6e2903d8ee..33d0c3ace9 100644 --- a/core/hashtables/hashtables.factor +++ b/core/hashtables/hashtables.factor @@ -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 : ( n -- array ) 3 * 1 + 2/ next-power-of-2 2 * +empty+ ; inline