Skip to content
This repository was archived by the owner on Dec 27, 2020. It is now read-only.

Commit 70192f5

Browse files
author
Andrea Corna
committed
LUAC: Remove weird number comparison, since delua doesn't make anymore rounding errors
1 parent 307730f commit 70192f5

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

tools/luac/rebase.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ void uniform_const_list(TProtoFunc* func, TProtoFunc* base) {
5151
for (j = j0; j < func->nconsts; ++j)
5252
if (cmp(&base->consts[i], &func->consts[j])) {
5353
j0 = j + 1;
54-
55-
//Set the value of numbers to the value of base functions
56-
//since they could be sligthly differents (rounding errors)
57-
if (ttype(&base->consts[i]) == LUA_T_NUMBER)
58-
nvalue(&func->consts[j]) = nvalue(&base->consts[i]);
5954
break;
6055
}
6156

@@ -323,24 +318,11 @@ bool cmp(const TObject *a, const TObject *b) {
323318
if (ttype(a) == LUA_T_PROTO)
324319
return true;
325320

326-
if (ttype(a) == LUA_T_NUMBER) {
327-
//A simple fp comparision
328-
double diff, fa, fb, largest;
329-
330-
diff = fabs(nvalue(a) - nvalue(b));
331-
fa = fabs(nvalue(a));
332-
fb = fabs(nvalue(b));
333-
largest = (fb > fa) ? fb : fa;
334-
335-
if (diff <= largest * 1e-5) //Ten parts in a million should be enough
336-
return true;
337-
else
338-
return false;
339-
}
321+
if (ttype(a) == LUA_T_NUMBER)
322+
return (nvalue(a) == nvalue(b));
340323

341324
if (ttype(a) == LUA_T_STRING)
342-
if (strncmp(svalue(a), svalue(b), tsvalue(a)->u.s.len) == 0)
343-
return true;
325+
return (strncmp(svalue(a), svalue(b), tsvalue(a)->u.s.len) == 0);
344326

345327
return false;
346328
}

0 commit comments

Comments
 (0)