Skip to content
Tcl Source Code View Ticket
Login

View Ticket

regexp/regsub operates veeery long on long strings sometimes

Closed / Fixed218859ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:06:47
OriginalBugID: 2440 Bug
Version: 8.1.1
SubmitDate: '1999-07-23'
LastModified: '1999-08-04'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: stanton
RelatedBugIDs: 2447
OS: Windows NT
OSVersion: v4.0 SP5 (Also on Win 98)
Machine: X86
FixedDate: '1999-08-04'
FixedInVersion: 8.2b3
ClosedDate: '2000-10-25'


Name:
Ingemar Hansson

ReproducibleScript:
# I'm interested in extracting a file name at the end of a line
    # The file name may contain white spaces
    # Generate a string that looks like the one I use (764 chars long)
    set line {tcc -o x:\xxx\xxx.o }
    for {set i 0} {$i < 20} {incr i} {
        append line {-x:\xxx_xxxxxx\xxxxxx\xxx_xx_xxxxx }
    }
    append line {z:\zzz_zzzzzz\zzzzzz\zzz_zz_zzzzzzz\zzzzzz.c}
    
    # This commands takes long time
    regexp -- {(?:tcc|tasm) -o .*? (.:.*)} $line "" file
    
    # This one is pretty fast
    regexp -- {(?:tcc|tasm) (-o .*?) (.:.*)} $line "" "" file
    
    # This one is also pretty fast
    regexp -- {(tcc|tasm) -o .*? (.:.*)} $line "" "" file
    
    # This one is really fast
    regexp -- {(tcc|tasm) -o .*? (.:.*)} $line "" "" file

ObservedBehavior:
The problem seems to be using of non-capturing parenthesis in a regular
    expression. In the example above "long time" is abour 5 seconds on a 266
    MHz Pentium II. "Pretty fast" is about 20 milliseconds and "really fast"
    is 1 millisecond.
    In my real case the strings are about 1500 characters long, and then the
    "long time" is about 50 seconds and "really fast" is about 3
    milliseconds.

DesiredBehavior:
Obviously I want to see "really fast" times in for any regular
    expression.



07/28/1999 14:46 - stanton - This is a major performance issue with regexp.  Henry Spencer is looking into the problem.

08/04/1999 17:45 - stanton - Applied a patch submitted by Henry that significantly improves the performance of these types of expression.
welch Closed ticket [218859ffff]. [History diff]2000-10-26 08:30:14
Log in (anonymous is fine) to add a comment.