Browse Source

Passing arguments by const reference to string_append and string_combine to avoid redundant memory duplication.

David Piuva 2 năm trước cách đây
mục cha
commit
137047938c
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      Source/DFPSR/api/stringAPI.h

+ 3 - 3
Source/DFPSR/api/stringAPI.h

@@ -342,19 +342,19 @@ void string_appendChar(String& target, DsrChar value);
 
 
 // Append one element
 // Append one element
 template<typename TYPE>
 template<typename TYPE>
-inline void string_append(String& target, TYPE value) {
+inline void string_append(String& target, const TYPE &value) {
 	string_toStream(target, value);
 	string_toStream(target, value);
 }
 }
 // Append multiple elements
 // Append multiple elements
 template<typename HEAD, typename... TAIL>
 template<typename HEAD, typename... TAIL>
-inline void string_append(String& target, HEAD head, TAIL... tail) {
+inline void string_append(String& target, HEAD head, TAIL&&... tail) {
 	string_append(target, head);
 	string_append(target, head);
 	string_append(target, tail...);
 	string_append(target, tail...);
 }
 }
 // Combine a number of strings, characters and numbers
 // Combine a number of strings, characters and numbers
 //   If an input type is rejected, create a Printable object to wrap around it
 //   If an input type is rejected, create a Printable object to wrap around it
 template<typename... ARGS>
 template<typename... ARGS>
-inline String string_combine(ARGS... args) {
+inline String string_combine(ARGS&&... args) {
 	String result;
 	String result;
 	string_append(result, args...);
 	string_append(result, args...);
 	return result;
 	return result;