]> granicus.if.org Git - taglib/commitdiff
Reduced a useless memory copy in tstring.cpp.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Sat, 15 Feb 2014 11:25:00 +0000 (20:25 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Sat, 15 Feb 2014 11:25:00 +0000 (20:25 +0900)
taglib/toolkit/tstring.cpp

index 774642a87ec725c72e6555b77f58eb4081bff35a..0151f784368fd9553cda04c0b96f15c1f440ab6b 100644 (file)
@@ -805,12 +805,13 @@ void String::copyFromUTF16(const wchar_t *s, size_t length, Type t)
 
   d->data.resize(length);
   if(length > 0) {
-    memcpy(&d->data[0], s, length * sizeof(wchar_t));
-
     if(swap) {
       for(size_t i = 0; i < length; ++i)
         d->data[i] = Utils::byteSwap(static_cast<ushort>(s[i]));
     }
+    else {
+      ::memcpy(&d->data[0], s, length * sizeof(wchar_t));
+    }
   }
 }