소스 검색

Apply patch from Mike Glenn\n2006-01-24 Mike Glenn <[email protected]>

	* StringBuilder.cs: Avoid computing computation for the string
	length twice.

svn path=/trunk/mcs/; revision=56001
Miguel de Icaza 20 년 전
부모
커밋
929bb68814
2개의 변경된 파일12개의 추가작업 그리고 7개의 파일을 삭제
  1. 5 0
      mcs/class/corlib/System.Text/ChangeLog
  2. 7 7
      mcs/class/corlib/System.Text/StringBuilder.cs

+ 5 - 0
mcs/class/corlib/System.Text/ChangeLog

@@ -1,3 +1,8 @@
+2006-01-24  Mike Glenn <[email protected]>
+
+	* StringBuilder.cs: Avoid computing computation for the string
+	length twice.
+
 2006-01-24  Atsushi Enomoto  <[email protected]>
 
 	* UTF8Encoding.cs : reverted the previous change. Looks like it broke

+ 7 - 7
mcs/class/corlib/System.Text/StringBuilder.cs

@@ -322,7 +322,7 @@ namespace System.Text {
 				InternalEnsureCapacity (needed_cap);
 			
 			String.InternalStrcpy (_str, _length, value);
-			_length += value.Length;
+			_length = needed_cap;
 
 			return this;
 		} 
@@ -343,7 +343,7 @@ namespace System.Text {
 				InternalEnsureCapacity (needed_cap);
 
 			String.InternalStrcpy (_str, _length, value);
-			_length += value.Length;
+			_length = needed_cap;
 			return this;
 		}
 
@@ -413,7 +413,7 @@ namespace System.Text {
 				InternalEnsureCapacity (needed_cap);
 
 			_str.InternalSetChar(_length, value);
-			_length++;
+			_length = needed_cap;
 
 			return this;
 		}
@@ -443,11 +443,11 @@ namespace System.Text {
 			if ((charCount < 0 || startIndex < 0) || (startIndex > value.Length - charCount)) 
 				throw new ArgumentOutOfRangeException();
 			
-			
-			InternalEnsureCapacity (_length + charCount);
+			int needed_cap = _length + charCount;
+			InternalEnsureCapacity (needed_cap);
 
 			String.InternalStrcpy (_str, _length, value, startIndex, charCount);
-			_length += charCount;
+			_length = needed_cap;
 
 			return this;
 		}
@@ -470,7 +470,7 @@ namespace System.Text {
 
 			String.InternalStrcpy (_str, _length, value, startIndex, count);
 			
-			_length += count;
+			_length = needed_cap;
 
 			return this;
 		}