Improve string view to reduce string allocation. (#6644)

This commit is contained in:
Jiaming Yuan
2021-01-27 19:08:52 +08:00
committed by GitHub
parent bc08e0c9d1
commit 1b70a323a7
4 changed files with 33 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
/*!
* Copyright (c) by Contributors 2019-2020
* Copyright (c) by Contributors 2019-2021
*/
#include <cctype>
#include <cstddef>
@@ -744,4 +744,11 @@ void Json::Dump(Json json, std::string* str) {
}
Json& Json::operator=(Json const &other) = default;
std::ostream &operator<<(std::ostream &os, StringView const v) {
for (auto c : v) {
os.put(c);
}
return os;
}
} // namespace xgboost