More work refactoring ckint/tryint/isint

This commit is contained in:
2024-03-15 12:50:08 -04:00
parent 26d0715deb
commit 3d6b5224f3
4 changed files with 64 additions and 51 deletions

View File

@@ -120,18 +120,18 @@ public:
// assign one.
int tabnum = 0;
LS.rawget(lchpos, tabchpos_, value);
if (!LS.isnumber(lchpos)) {
auto chpos = LS.tryint(lchpos);
if (!chpos) {
// First time. Record the character position where the
// table first appears in the output stream.
LS.rawset(tabchpos_, value, int((*output_).tellp()));
} else {
int chpos = LS.ckint(lchpos);
tabnum = chpos_to_tabnum_[chpos];
tabnum = chpos_to_tabnum_[*chpos];
if (tabnum == 0) {
// Second time. The table is already in the output,
// but it hasn't been assigned a number. Assign one.
tabnum = next_id_++;
chpos_to_tabnum_[chpos] = tabnum;
chpos_to_tabnum_[*chpos] = tabnum;
}
}