aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-10-22 15:54:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-10-22 15:54:46 -0300
commitd742a193e57029d973aff0a5eb04d8ddd03fa0ff (patch)
treef0850c8f60997909952cbb1db3f499f066fb1188 /ltable.c
parente4a38eb0e828e9589c391171e2e1904a3b9698e7 (diff)
downloadlua-d742a193e57029d973aff0a5eb04d8ddd03fa0ff.tar.gz
lua-d742a193e57029d973aff0a5eb04d8ddd03fa0ff.tar.bz2
lua-d742a193e57029d973aff0a5eb04d8ddd03fa0ff.zip
Comments
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/ltable.c b/ltable.c
index 38bee1dc..7e7cbed9 100644
--- a/ltable.c
+++ b/ltable.c
@@ -166,17 +166,24 @@ static Node *mainpositionTV (const Table *t, const TValue *key) {
166 166
167 167
168/* 168/*
169** Check whether key 'k1' is equal to the key in node 'n2'. 169** Check whether key 'k1' is equal to the key in node 'n2'. This
170** This equality is raw, so there are no metamethods. Floats 170** equality is raw, so there are no metamethods. Floats with integer
171** with integer values have been normalized, so integers cannot 171** values have been normalized, so integers cannot be equal to
172** be equal to floats. It is assumed that 'eqshrstr' is simply 172** floats. It is assumed that 'eqshrstr' is simply pointer equality, so
173** pointer equality, so that short strings are handled in the 173** that short strings are handled in the default case.
174** default case.
175** A true 'deadok' means to accept dead keys as equal to their original 174** A true 'deadok' means to accept dead keys as equal to their original
176** values, which can only happen if the original key was collectable. 175** values. All dead keys are compared in the default case, by pointer
177** All dead values are compared in the default case, by pointer 176** identity. (Only collectable objects can produce dead keys.) Note that
178** identity. (Note that dead long strings are also compared by 177** dead long strings are also compared by identity.
179** identity). 178** Once a key is dead, its corresponding value may be collected, and
179** then another value can be created with the same address. If this
180** other value is given to 'next', 'equalkey' will signal a false
181** positive. In a regular traversal, this situation should never happen,
182** as all keys given to 'next' came from the table itself, and therefore
183** could not have been collected. Outside a regular traversal, we
184** have garbage in, garbage out. What is relevant is that this false
185** positive does not break anything. (In particular, 'next' will return
186** some other valid item on the table or nil.)
180*/ 187*/
181static int equalkey (const TValue *k1, const Node *n2, int deadok) { 188static int equalkey (const TValue *k1, const Node *n2, int deadok) {
182 if ((rawtt(k1) != keytt(n2)) && /* not the same variants? */ 189 if ((rawtt(k1) != keytt(n2)) && /* not the same variants? */