• R/O
  • SSH

quipu: Commit

quipu mercurial repository


Commit MetaInfo

Revision5bea331233ee467d81e296a8a504a707c4fa8d1f (tree)
Zeit2019-09-12 06:19:01
AutorAgustina Arzille <avarzille@rise...>
CommiterAgustina Arzille

Log Message

Fix key comparisons in table implementation

Ändern Zusammenfassung

Diff

diff -r 0ec864a37d94 -r 5bea331233ee table.cpp
--- a/table.cpp Wed Sep 11 16:20:16 2019 -0300
+++ b/table.cpp Wed Sep 11 18:19:01 2019 -0300
@@ -36,29 +36,6 @@
3636 return (idx * 2);
3737 }
3838
39-static inline bool
40-table_equal (interpreter *interp, const table *tp,
41- object k1, object k2)
42-{
43- // We only need to save K1, since K2 is the caller-provided key.
44- valref tmp (interp, k1);
45- if (tp->cmpfct == UNBOUND)
46- return (equal (interp, k1, k2));
47-
48- return (QP_CALL (interp, tp->cmpfct, k1, k2) != NIL);
49-}
50-
51-static inline uint32_t
52-table_hash (interpreter *interp, const table *tp, object key)
53-{
54- if (tp->hashfct == UNBOUND)
55- return (xhash (interp, key));
56- else if (!fixint_p (QP_CALL (interp, tp->hashfct, key)))
57- interp->raise ("type-error", "hash function did not return an integer");
58-
59- return ((uint32_t)as_int (interp->retval));
60-}
61-
6239 static const uint32_t SECONDARY_KEYS[] = { 2, 3, 5, 7 };
6340 static const int N_SECONDARY_KEYS = QP_NELEM (SECONDARY_KEYS);
6441
@@ -141,6 +118,32 @@
141118 return (interp->alval);
142119 }
143120
121+static inline bool
122+table_equal (interpreter *interp, const table *tp,
123+ object k1, object k2)
124+{
125+ if (k1 == DELETED_KEY)
126+ return (false);
127+
128+ // We only need to save K1, since K2 is the caller-provided key.
129+ valref tmp (interp, k1);
130+ if (tp->cmpfct == UNBOUND)
131+ return (equal (interp, k1, k2));
132+
133+ return (QP_CALL (interp, tp->cmpfct, k1, k2) != NIL);
134+}
135+
136+static inline uint32_t
137+table_hash (interpreter *interp, const table *tp, object key)
138+{
139+ if (tp->hashfct == UNBOUND)
140+ return (xhash (interp, key));
141+ else if (!fixint_p (QP_CALL (interp, tp->hashfct, key)))
142+ interp->raise ("type-error", "hash function did not return an integer");
143+
144+ return ((uint32_t)as_int (interp->retval));
145+}
146+
144147 #ifndef QP_HAS_ATOMIC_CASX
145148
146149 // Try to atomically set the key in the table vector.
Show on old repository browser