summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclUtil.c10
2 files changed, 11 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 6b4c8e2..c3e8965 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-06-03 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * generic/tclUtil.c (Tcl_DStringAppendElement): patch to save an
+ extra strlen call. [Bug #428572]
+
2001-05-30 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* generic/tclExecute.c (TclExecuteByteCode): Added two casts to
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 8a2aa94..bd75075 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.18 2000/05/08 21:59:59 hobbs Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.19 2001/06/04 01:25:04 hobbs Exp $
*/
#include "tclInt.h"
@@ -1450,10 +1450,12 @@ Tcl_DStringAppendElement(dsPtr, string)
CONST char *string; /* String to append. Must be
* null-terminated. */
{
- int newSize, flags;
+ int newSize, flags, strSize;
char *dst;
- newSize = Tcl_ScanElement(string, &flags) + dsPtr->length + 1;
+ strSize = ((string == NULL) ? 0 : strlen(string));
+ newSize = Tcl_ScanCountedElement(string, strSize, &flags)
+ + dsPtr->length + 1;
/*
* Allocate a larger buffer for the string if the current one isn't
@@ -1490,7 +1492,7 @@ Tcl_DStringAppendElement(dsPtr, string)
dst++;
dsPtr->length++;
}
- dsPtr->length += Tcl_ConvertElement(string, dst, flags);
+ dsPtr->length += Tcl_ConvertCountedElement(string, strSize, dst, flags);
return dsPtr->string;
}