Subject: Eliminate the copy to a staging buffer when that serves no functional purpose.

From: dgp <[email-masked]>
Date: Fri, 24 Jan 2014 17:38:59 +0000

---
 generic/tclIO.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/generic/tclIO.c b/generic/tclIO.c
index f1d8909..13494ca 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -3787,16 +3787,17 @@ WriteChars(
     consumedSomething = 1;
     while (consumedSomething && (srcLen + savedLF + endEncoding > 0)) {
 	consumedSomething = 0;
-	stage = statePtr->outputStage;
-	stageMax = statePtr->bufSize;
-	stageLen = stageMax;
-
-	toWrite = stageLen;
-	if (toWrite > srcLen) {
-	    toWrite = srcLen;
-	}
 
 	if (translate) {
+	    stage = statePtr->outputStage;
+	    stageMax = statePtr->bufSize;
+	    stageLen = stageMax;
+
+	    toWrite = stageLen;
+	    if (toWrite > srcLen) {
+		toWrite = srcLen;
+	    }
+
 	    if (savedLF) {
 		/*
 		 * A '\n' was left over from last call to TranslateOutputEOL()
@@ -3822,8 +3823,9 @@ WriteChars(
 		stageLen = stageMax;
 	    }
 	} else {
-	    memcpy(stage, src, toWrite);
-	    stageLen = toWrite;
+	    stage = (char *) src;
+	    stageLen = srcLen;
+	    toWrite = stageLen;
 	}
 	src += toWrite;
 	srcLen -= toWrite;
-- 
cgit v0.12