[select] Add zero-copy support for API select commands (#12329)

This commit is contained in:
J. Nick Koston
2025-12-08 10:37:51 -05:00
committed by GitHub
parent d635892ecf
commit 801d1135ab
9 changed files with 27 additions and 24 deletions
+2 -4
View File
@@ -56,12 +56,10 @@ size_t Select::size() const {
return options.size();
}
optional<size_t> Select::index_of(const std::string &option) const { return this->index_of(option.c_str()); }
optional<size_t> Select::index_of(const char *option) const {
optional<size_t> Select::index_of(const char *option, size_t len) const {
const auto &options = traits.get_options();
for (size_t i = 0; i < options.size(); i++) {
if (strcmp(options[i], option) == 0) {
if (strncmp(options[i], option, len) == 0 && options[i][len] == '\0') {
return i;
}
}