Tcl Source Code

View Ticket
Login
Ticket UUID: 1165671
Title: inefficient bytecode for [incr x -1]
Type: Bug Created on: 2005-03-17 23:42:19
Submitter: dgp Assigned to: dgp
Subsystem: 47. Bytecode Compiler Severity:
Priority: 5 Medium Last modified: 2005-03-18 22:32:33
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2005-03-18 15:32:33
Version: obsolete: 8.4.9
Description:
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.
User Comments:
dgp added on 2005-03-18 06:42:21:

File Added - 126170: immincr.patch

dgp added on 2005-03-18 22:32:33:
Logged In: YES 
user_id=80530


fix committed for 8.4.10 and 8.5a3

Attachments: