Переглянути джерело

Skip unnecessary resize check.

woollybah 6 роки тому
батько
коміт
2171f3be9b
1 змінених файлів з 4 додано та 4 видалено
  1. 4 4
      stringbuilder.mod/glue.c

+ 4 - 4
stringbuilder.mod/glue.c

@@ -605,11 +605,11 @@ int bmx_stringbuilder_compare(struct MaxStringBuilder * buf1, struct MaxStringBu
 }
 
 void bmx_stringbuilder_leftalign(struct MaxStringBuilder * buf, int length) {
-	bmx_stringbuilder_resize(buf, length);
-	
 	if (length == buf->count) {
 		return;
 	} else if (length > buf->count) {
+		bmx_stringbuilder_resize(buf, length);
+
 		int c = length - buf->count;
 
 		BBChar * p = buf->buffer + buf->count;
@@ -623,14 +623,14 @@ void bmx_stringbuilder_leftalign(struct MaxStringBuilder * buf, int length) {
 }
 
 void bmx_stringbuilder_rightalign(struct MaxStringBuilder * buf, int length) {
-	bmx_stringbuilder_resize(buf, length);
-
 	if (length == buf->count) {
 		return;
 	} else if (length < buf->count) {
 		int offset = buf->count - length;
 		memmove(buf->buffer, buf->buffer + offset, buf->count * sizeof(BBChar));
 	} else {
+		bmx_stringbuilder_resize(buf, length);
+
 		int offset = length - buf->count;
 		
 		if (offset == 0) {