zhiics commented on a change in pull request #5806:
URL: https://github.com/apache/incubator-tvm/pull/5806#discussion_r441138133
##########
File path: include/tvm/runtime/container.h
##########
@@ -1410,10 +1369,107 @@ inline String& String::operator=(std::string other) {
inline String& String::operator=(const char* other) { return
operator=(std::string(other)); }
-inline String operator+(const std::string lhs, const String& rhs) {
- return lhs + rhs.operator std::string();
+inline String operator+(const String& lhs, const String& rhs) {
+ size_t lhs_size = lhs.size();
+ size_t rhs_size = rhs.size();
+ char* concat = String::Concat(lhs.data(), lhs_size, rhs.data(), rhs_size);
+ return String(concat);
}
+inline String operator+(const String& lhs, const std::string& rhs) {
+ size_t lhs_size = lhs.size();
+ size_t rhs_size = rhs.size();
+ char* concat = String::Concat(lhs.data(), lhs_size, rhs.data(), rhs_size);
+ return String(concat);
+}
+
+inline String operator+(const std::string& lhs, const String& rhs) {
+ size_t lhs_size = lhs.size();
+ size_t rhs_size = rhs.size();
+ char* concat = String::Concat(lhs.data(), lhs_size, rhs.data(), rhs_size);
+ return String(concat);
+}
+
+inline String operator+(const char* lhs, const String& rhs) {
+ size_t lhs_size = std::strlen(lhs);
+ size_t rhs_size = rhs.size();
+ char* concat = String::Concat(lhs, lhs_size, rhs.data(), rhs_size);
+ return String(concat);
+}
+
+inline String operator+(const String& lhs, const char* rhs) {
+ size_t lhs_size = lhs.size();
+ size_t rhs_size = std::strlen(rhs);
+ char* concat = String::Concat(lhs.data(), lhs_size, rhs, rhs_size);
+ return String(concat);
+}
+
+// Overload < operator
+inline bool operator<(const String& lhs, const std::string& rhs) { return
lhs.compare(rhs) < 0; }
Review comment:
Thanks for suggestion. I would keep the current form as they are already
one-liners.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]