diff --git a/velox/type/Type.cpp b/velox/type/Type.cpp index b07c6f07f806..f6411f5c8117 100644 --- a/velox/type/Type.cpp +++ b/velox/type/Type.cpp @@ -421,7 +421,7 @@ bool RowType::containsChild(std::string_view name) const { return std::find(names_.begin(), names_.end(), name) != names_.end(); } -uint32_t RowType::getChildIdx(const std::string& name) const { +uint32_t RowType::getChildIdx(std::string_view name) const { auto index = getChildIdxIfExists(name); if (!index.has_value()) { VELOX_USER_FAIL(makeFieldNotFoundErrorMessage(name, names_)); @@ -430,7 +430,7 @@ uint32_t RowType::getChildIdx(const std::string& name) const { } std::optional RowType::getChildIdxIfExists( - const std::string& name) const { + std::string_view name) const { for (uint32_t i = 0; i < names_.size(); i++) { if (names_.at(i) == name) { return i; diff --git a/velox/type/Type.h b/velox/type/Type.h index 6a0b5610bcb6..1ed7ba5c09a0 100644 --- a/velox/type/Type.h +++ b/velox/type/Type.h @@ -1026,9 +1026,9 @@ class RowType : public TypeBase { bool containsChild(std::string_view name) const; - uint32_t getChildIdx(const std::string& name) const; + uint32_t getChildIdx(std::string_view name) const; - std::optional getChildIdxIfExists(const std::string& name) const; + std::optional getChildIdxIfExists(std::string_view name) const; const std::string& nameOf(uint32_t idx) const { VELOX_CHECK_LT(idx, names_.size());