Skip to content

Commit 482e817

Browse files
committed
parser: Accelerate and improve object parsing
Scan characters ahead of time in order to accelerate parsing. This also solves various problem parsing units inside expressions, or detecting error conditions such as `1.0+`. While the functional improvements are numerous, the performance one is just not there, for a reason that remains to be investigated: Time to parse `DEMO.48S`, as measured by running `TEval` on `« "/STATE/DEMO.48S" RCL »`: Before: 358ms (DM32) 259ms (DM42) After: 427ms (DM32) 349ms (DM42) Note that the main objective is not just performance, but also improving battery life by reducing CPU utilization for a very common operation. So it matters that we do not have a regression. Fixes: #940 Signed-off-by: Christophe de Dinechin <[email protected]>
1 parent 2cb9484 commit 482e817

20 files changed

+449
-497
lines changed

src/bignum.cc

-9
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ integer_p bignum::as_integer() const
102102
}
103103

104104

105-
PARSE_BODY(bignum)
106-
// ----------------------------------------------------------------------------
107-
// Bignums are parsed by integer parser, so we can skip here
108-
// ----------------------------------------------------------------------------
109-
{
110-
return SKIP;
111-
}
112-
113-
114105
HELP_BODY(bignum)
115106
// ----------------------------------------------------------------------------
116107
// Help topic for big integers

src/bignum.h

-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ struct bignum : text
194194

195195
public:
196196
OBJECT_DECL(bignum);
197-
PARSE_DECL(bignum);
198197
RENDER_DECL(bignum);
199198
HELP_DECL(bignum);
200199
};

src/command.cc

+2-7
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ PARSE_BODY(command)
6565
// Try to parse this as a command, using either short or long name
6666
// ----------------------------------------------------------------------------
6767
{
68-
// We scan all the commands in one loop under 'Drop'. Skip all other
69-
id i = p.candidate;
70-
if (i != ID_Drop)
71-
return SKIP;
72-
7368
bool eq = p.precedence;
7469
id type = id(0);
7570
id found = id(0);
@@ -113,8 +108,8 @@ PARSE_BODY(command)
113108
}
114109

115110
record(command,
116-
"Parsing [%s] with id %u %+s (%+s), found %u len %u",
117-
ref, i, name(i), fancy(i), found, len);
111+
"Parsing [%s] found %u %+s %+s len %u",
112+
ref, found, name(found), fancy(found), len);
118113

119114
if (!found)
120115
return SKIP;

0 commit comments

Comments
 (0)