Skip to content
Tcl Source Code View Ticket
Login

View Ticket

inefficient bytecode for [incr x -1]

Closed / Fixed1165671fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-03-17 23:42:19
During the CONST reforms leading up
to Tcl 8.4 that allowed const strings
to be passed to Tcl_Eval(), etc...
a call to TclLooksLikeInt() was replaced
by TclParseInteger() in the
TclCompileIncrCmd() routine.

TclLooksLikeInt() allows for leading
whitespce and + and -, while TclParseInteger()
does not.  So the test doesn't pass as
often as it used to, or as it should.
When the test passes, immediate
operands are compiled into the
bytecode allowing for more efficient
execution.

As it happems, TclLooksLikeInt()
is happy and safe to use with const
strings.  The attached patch restores
it, which allows increments containing
whitespace and leading sign characters
to be compiled to more efficient bytecode.
The most notable case is probably
[incr x -1].  Will be interesting to see if
this change shows up in any benchmarks.
dgpplain2005-03-18 06:42:21
File Added - 126170: immincr.patch
dgp Closed ticket [1165671fff]. [History diff]2005-03-18 22:32:32
dgpplain2005-03-18 22:32:33
Logged In: YES 
user_id=80530


fix committed for 8.4.10 and 8.5a3
Log in (anonymous is fine) to add a comment.

Attachments: