jscript: Optimized concatenation of empty strings.
This commit is contained in:
parent
f0c0c14241
commit
0e6d3b8611
|
@ -72,16 +72,19 @@ jsstr_t *jsstr_concat(jsstr_t *str1, jsstr_t *str2)
|
|||
jsstr_t *ret;
|
||||
|
||||
len1 = jsstr_length(str1);
|
||||
if(!len1)
|
||||
return jsstr_addref(str2);
|
||||
|
||||
len2 = jsstr_length(str2);
|
||||
if(!len2)
|
||||
return jsstr_addref(str1);
|
||||
|
||||
ret = jsstr_alloc_buf(len1+len2);
|
||||
if(!ret)
|
||||
return NULL;
|
||||
|
||||
if(len1)
|
||||
memcpy(ret->str, str1->str, len1*sizeof(WCHAR));
|
||||
if(len2)
|
||||
memcpy(ret->str+len1, str2->str, len2*sizeof(WCHAR));
|
||||
memcpy(ret->str, str1->str, len1*sizeof(WCHAR));
|
||||
memcpy(ret->str+len1, str2->str, len2*sizeof(WCHAR));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue