diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-06-26 07:51:22 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-06-26 07:51:22 (GMT) |
commit | 2b756b48f0fcb3c5117930e9ad1be22561d9728b (patch) | |
tree | 18e0110c3a4f6b3589872553b3e0db9a7209d300 /generic/tclUtil.c | |
parent | 8211d5bc63a57a3d51b8f6c605a9e4e4a992a6ec (diff) | |
parent | 94c255833358445b9edae73af1ffbe1cc2c8ab42 (diff) | |
download | tcl-drh_micro_optimization.zip tcl-drh_micro_optimization.tar.gz tcl-drh_micro_optimization.tar.bz2 |
Merge trunkdrh_micro_optimization
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 2b0fb72..553593c 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -2634,7 +2634,19 @@ Tcl_DStringAppend( memcpy(newString, dsPtr->string, (size_t) dsPtr->length); dsPtr->string = newString; } else { + int offset = -1; + + /* See [16896d49fd] */ + if (bytes >= dsPtr->string + && bytes <= dsPtr->string + dsPtr->length) { + offset = bytes - dsPtr->string; + } + dsPtr->string = ckrealloc(dsPtr->string, dsPtr->spaceAvl); + + if (offset >= 0) { + bytes = dsPtr->string + offset; + } } } @@ -2725,7 +2737,19 @@ Tcl_DStringAppendElement( memcpy(newString, dsPtr->string, (size_t) dsPtr->length); dsPtr->string = newString; } else { + int offset = -1; + + /* See [16896d49fd] */ + if (element >= dsPtr->string + && element <= dsPtr->string + dsPtr->length) { + offset = element - dsPtr->string; + } + dsPtr->string = ckrealloc(dsPtr->string, dsPtr->spaceAvl); + + if (offset >= 0) { + element = dsPtr->string + offset; + } } dst = dsPtr->string + dsPtr->length; } |