Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-06-04
08:23 • Closed ticket [428572ffff]: Tcl_DStringAppendElement speedup plus 7 other ch... artifact: a0cd94edff user: hobbs
2001-05-30
07:04 • New ticket [428572ffff]. artifact: 1cc51195d0 user: nobody

Tcl_DStringAppendElement speedup

Closed / Fixed428572ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2001-05-30 07:04:45
This patch avoids a repeated strlen call by using
the Counted versions of ScanElement and ConvertElement.

Index: tclUtil.c
=======================================================
============
RCS file: /cvsroot/tcl/tcl/generic/tclUtil.c,v
retrieving revision 1.18
diff -c -r1.18 tclUtil.c
*** tclUtil.c   2000/05/08 21:59:59     1.18
--- tclUtil.c   2001/05/30 06:57:32
***************
*** 1452,1459 ****
  {
      int newSize, flags;
      char *dst;
  
!     newSize = Tcl_ScanElement(string, &flags) + 
dsPtr->length + 1;
  
      /*
       * Allocate a larger buffer for the string if 
the current one isn't
--- 1452,1461 ----
  {
      int newSize, flags;
      char *dst;
+     int stringSize;
  
!     stringSize = strlen (string);
!     newSize = Tcl_ScanCountedElement(string, 
stringSize, &flags) + dsPtr->length + 1;
  
      /*
       * Allocate a larger buffer for the string if 
the current one isn't
***************
*** 1490,1496 ****
        dst++;
        dsPtr->length++;
      }
!     dsPtr->length += Tcl_ConvertElement(string, dst, 
flags);
      return dsPtr->string;
  }
  

--- 1492,1498 ----
        dst++;
        dsPtr->length++;
      }
!     dsPtr->length += Tcl_ConvertCountedElement
(string, stringSize, dst, flags);
      return dsPtr->string;
  }
hobbsplain2001-06-04 08:23:55
Logged In: YES 
user_id=72656

patched into 8.4a3cvs.
Log in (anonymous is fine) to add a comment.