mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Add string view overloads (#1154)
Some checks failed
Build / Bazel, cl, windows-latest (push) Has been cancelled
Build / Bazel, clang++, macos-latest (push) Has been cancelled
Build / Bazel, clang++, ubuntu-latest (push) Has been cancelled
Build / Bazel, g++, macos-latest (push) Has been cancelled
Build / Bazel, g++, ubuntu-latest (push) Has been cancelled
Build / CMake, cl, windows-latest (push) Has been cancelled
Build / CMake, gcc, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, macos-latest (push) Has been cancelled
Build / Test modules (llvm, ubuntu-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
Some checks failed
Build / Bazel, cl, windows-latest (push) Has been cancelled
Build / Bazel, clang++, macos-latest (push) Has been cancelled
Build / Bazel, clang++, ubuntu-latest (push) Has been cancelled
Build / Bazel, g++, macos-latest (push) Has been cancelled
Build / Bazel, g++, ubuntu-latest (push) Has been cancelled
Build / CMake, cl, windows-latest (push) Has been cancelled
Build / CMake, gcc, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, macos-latest (push) Has been cancelled
Build / Test modules (llvm, ubuntu-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
This is better ergonomic, as `std::string_view` is lightweight and accept more conversion than `const std::string&`. Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
@@ -531,7 +531,7 @@ void Screen::ApplyShader() {
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
std::uint8_t Screen::RegisterHyperlink(const std::string& link) {
|
||||
std::uint8_t Screen::RegisterHyperlink(std::string_view link) {
|
||||
for (std::size_t i = 0; i < hyperlinks_.size(); ++i) {
|
||||
if (hyperlinks_[i] == link) {
|
||||
return i;
|
||||
@@ -540,7 +540,7 @@ std::uint8_t Screen::RegisterHyperlink(const std::string& link) {
|
||||
if (hyperlinks_.size() == std::numeric_limits<std::uint8_t>::max()) {
|
||||
return 0;
|
||||
}
|
||||
hyperlinks_.push_back(link);
|
||||
hyperlinks_.push_back(std::string(link));
|
||||
return hyperlinks_.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user