diff --git a/BUILD b/BUILD
index 99d1be772b7..71485338ba2 100644
--- a/BUILD
+++ b/BUILD
@@ -1585,6 +1585,7 @@ grpc_cc_library(
"//src/core:promise_status",
"//src/core:race",
"//src/core:ref_counted",
+ "//src/core:ref_counted_string",
"//src/core:resolved_address",
"//src/core:resource_quota",
"//src/core:resource_quota_trace",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ba2aee3f17..e73ed867506 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2196,6 +2196,7 @@ add_library(grpc
src/core/lib/experiments/experiments.cc
src/core/lib/gprpp/load_file.cc
src/core/lib/gprpp/per_cpu.cc
+ src/core/lib/gprpp/ref_counted_string.cc
src/core/lib/gprpp/status_helper.cc
src/core/lib/gprpp/time.cc
src/core/lib/gprpp/time_averaged_stats.cc
@@ -2901,6 +2902,7 @@ add_library(grpc_unsecure
src/core/lib/experiments/experiments.cc
src/core/lib/gprpp/load_file.cc
src/core/lib/gprpp/per_cpu.cc
+ src/core/lib/gprpp/ref_counted_string.cc
src/core/lib/gprpp/status_helper.cc
src/core/lib/gprpp/time.cc
src/core/lib/gprpp/time_averaged_stats.cc
@@ -4798,6 +4800,7 @@ add_library(grpc_authorization_provider
src/core/lib/experiments/experiments.cc
src/core/lib/gprpp/load_file.cc
src/core/lib/gprpp/per_cpu.cc
+ src/core/lib/gprpp/ref_counted_string.cc
src/core/lib/gprpp/status_helper.cc
src/core/lib/gprpp/time.cc
src/core/lib/gprpp/time_averaged_stats.cc
@@ -10510,6 +10513,7 @@ if(gRPC_BUILD_TESTS)
add_executable(endpoint_config_test
src/core/lib/channel/channel_args.cc
src/core/lib/event_engine/channel_args_endpoint_config.cc
+ src/core/lib/gprpp/ref_counted_string.cc
src/core/lib/gprpp/time.cc
src/core/lib/surface/channel_stack_type.cc
test/core/event_engine/endpoint_config_test.cc
@@ -12091,6 +12095,7 @@ add_executable(frame_test
src/core/lib/experiments/experiments.cc
src/core/lib/gprpp/load_file.cc
src/core/lib/gprpp/per_cpu.cc
+ src/core/lib/gprpp/ref_counted_string.cc
src/core/lib/gprpp/status_helper.cc
src/core/lib/gprpp/time.cc
src/core/lib/gprpp/time_averaged_stats.cc
diff --git a/Makefile b/Makefile
index c7f498c57de..d0d49b15a14 100644
--- a/Makefile
+++ b/Makefile
@@ -1479,6 +1479,7 @@ LIBGRPC_SRC = \
src/core/lib/experiments/experiments.cc \
src/core/lib/gprpp/load_file.cc \
src/core/lib/gprpp/per_cpu.cc \
+ src/core/lib/gprpp/ref_counted_string.cc \
src/core/lib/gprpp/status_helper.cc \
src/core/lib/gprpp/time.cc \
src/core/lib/gprpp/time_averaged_stats.cc \
@@ -2045,6 +2046,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/experiments/experiments.cc \
src/core/lib/gprpp/load_file.cc \
src/core/lib/gprpp/per_cpu.cc \
+ src/core/lib/gprpp/ref_counted_string.cc \
src/core/lib/gprpp/status_helper.cc \
src/core/lib/gprpp/time.cc \
src/core/lib/gprpp/time_averaged_stats.cc \
diff --git a/Package.swift b/Package.swift
index 17c4cedb05b..8ab107515be 100644
--- a/Package.swift
+++ b/Package.swift
@@ -1239,6 +1239,8 @@ let package = Package(
"src/core/lib/gprpp/posix/thd.cc",
"src/core/lib/gprpp/ref_counted.h",
"src/core/lib/gprpp/ref_counted_ptr.h",
+ "src/core/lib/gprpp/ref_counted_string.cc",
+ "src/core/lib/gprpp/ref_counted_string.h",
"src/core/lib/gprpp/single_set_ptr.h",
"src/core/lib/gprpp/sorted_pack.h",
"src/core/lib/gprpp/stat.h",
diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml
index 7e640d1fc07..73c018b8fcd 100644
--- a/build_autogenerated.yaml
+++ b/build_autogenerated.yaml
@@ -756,6 +756,7 @@ libs:
- src/core/lib/gprpp/per_cpu.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
+ - src/core/lib/gprpp/ref_counted_string.h
- src/core/lib/gprpp/single_set_ptr.h
- src/core/lib/gprpp/sorted_pack.h
- src/core/lib/gprpp/status_helper.h
@@ -1550,6 +1551,7 @@ libs:
- src/core/lib/experiments/experiments.cc
- src/core/lib/gprpp/load_file.cc
- src/core/lib/gprpp/per_cpu.cc
+ - src/core/lib/gprpp/ref_counted_string.cc
- src/core/lib/gprpp/status_helper.cc
- src/core/lib/gprpp/time.cc
- src/core/lib/gprpp/time_averaged_stats.cc
@@ -2161,6 +2163,7 @@ libs:
- src/core/lib/gprpp/per_cpu.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
+ - src/core/lib/gprpp/ref_counted_string.h
- src/core/lib/gprpp/single_set_ptr.h
- src/core/lib/gprpp/sorted_pack.h
- src/core/lib/gprpp/status_helper.h
@@ -2562,6 +2565,7 @@ libs:
- src/core/lib/experiments/experiments.cc
- src/core/lib/gprpp/load_file.cc
- src/core/lib/gprpp/per_cpu.cc
+ - src/core/lib/gprpp/ref_counted_string.cc
- src/core/lib/gprpp/status_helper.cc
- src/core/lib/gprpp/time.cc
- src/core/lib/gprpp/time_averaged_stats.cc
@@ -4125,6 +4129,7 @@ libs:
- src/core/lib/gprpp/per_cpu.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
+ - src/core/lib/gprpp/ref_counted_string.h
- src/core/lib/gprpp/sorted_pack.h
- src/core/lib/gprpp/status_helper.h
- src/core/lib/gprpp/table.h
@@ -4406,6 +4411,7 @@ libs:
- src/core/lib/experiments/experiments.cc
- src/core/lib/gprpp/load_file.cc
- src/core/lib/gprpp/per_cpu.cc
+ - src/core/lib/gprpp/ref_counted_string.cc
- src/core/lib/gprpp/status_helper.cc
- src/core/lib/gprpp/time.cc
- src/core/lib/gprpp/time_averaged_stats.cc
@@ -7644,11 +7650,13 @@ targets:
- src/core/lib/gprpp/orphanable.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
+ - src/core/lib/gprpp/ref_counted_string.h
- src/core/lib/gprpp/time.h
- src/core/lib/surface/channel_stack_type.h
src:
- src/core/lib/channel/channel_args.cc
- src/core/lib/event_engine/channel_args_endpoint_config.cc
+ - src/core/lib/gprpp/ref_counted_string.cc
- src/core/lib/gprpp/time.cc
- src/core/lib/surface/channel_stack_type.cc
- test/core/event_engine/endpoint_config_test.cc
@@ -8770,6 +8778,7 @@ targets:
- src/core/lib/gprpp/per_cpu.h
- src/core/lib/gprpp/ref_counted.h
- src/core/lib/gprpp/ref_counted_ptr.h
+ - src/core/lib/gprpp/ref_counted_string.h
- src/core/lib/gprpp/sorted_pack.h
- src/core/lib/gprpp/status_helper.h
- src/core/lib/gprpp/table.h
@@ -9033,6 +9042,7 @@ targets:
- src/core/lib/experiments/experiments.cc
- src/core/lib/gprpp/load_file.cc
- src/core/lib/gprpp/per_cpu.cc
+ - src/core/lib/gprpp/ref_counted_string.cc
- src/core/lib/gprpp/status_helper.cc
- src/core/lib/gprpp/time.cc
- src/core/lib/gprpp/time_averaged_stats.cc
diff --git a/config.m4 b/config.m4
index 52d064461ba..584c7fdab45 100644
--- a/config.m4
+++ b/config.m4
@@ -606,6 +606,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/gprpp/posix/env.cc \
src/core/lib/gprpp/posix/stat.cc \
src/core/lib/gprpp/posix/thd.cc \
+ src/core/lib/gprpp/ref_counted_string.cc \
src/core/lib/gprpp/status_helper.cc \
src/core/lib/gprpp/strerror.cc \
src/core/lib/gprpp/tchar.cc \
diff --git a/config.w32 b/config.w32
index 192db270f13..bc39c417066 100644
--- a/config.w32
+++ b/config.w32
@@ -571,6 +571,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\gprpp\\posix\\env.cc " +
"src\\core\\lib\\gprpp\\posix\\stat.cc " +
"src\\core\\lib\\gprpp\\posix\\thd.cc " +
+ "src\\core\\lib\\gprpp\\ref_counted_string.cc " +
"src\\core\\lib\\gprpp\\status_helper.cc " +
"src\\core\\lib\\gprpp\\strerror.cc " +
"src\\core\\lib\\gprpp\\tchar.cc " +
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
index 74e72fcab62..f95f144545c 100644
--- a/gRPC-C++.podspec
+++ b/gRPC-C++.podspec
@@ -844,6 +844,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/per_cpu.h',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
+ 'src/core/lib/gprpp/ref_counted_string.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/sorted_pack.h',
'src/core/lib/gprpp/stat.h',
@@ -1900,6 +1901,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/per_cpu.h',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
+ 'src/core/lib/gprpp/ref_counted_string.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/sorted_pack.h',
'src/core/lib/gprpp/stat.h',
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 940658b9920..dcd7f2bda34 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -1340,6 +1340,8 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/posix/thd.cc',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
+ 'src/core/lib/gprpp/ref_counted_string.cc',
+ 'src/core/lib/gprpp/ref_counted_string.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/sorted_pack.h',
'src/core/lib/gprpp/stat.h',
@@ -2647,6 +2649,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/per_cpu.h',
'src/core/lib/gprpp/ref_counted.h',
'src/core/lib/gprpp/ref_counted_ptr.h',
+ 'src/core/lib/gprpp/ref_counted_string.h',
'src/core/lib/gprpp/single_set_ptr.h',
'src/core/lib/gprpp/sorted_pack.h',
'src/core/lib/gprpp/stat.h',
diff --git a/grpc.gemspec b/grpc.gemspec
index 4ffcc56765e..944dba89cee 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -1245,6 +1245,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gprpp/posix/thd.cc )
s.files += %w( src/core/lib/gprpp/ref_counted.h )
s.files += %w( src/core/lib/gprpp/ref_counted_ptr.h )
+ s.files += %w( src/core/lib/gprpp/ref_counted_string.cc )
+ s.files += %w( src/core/lib/gprpp/ref_counted_string.h )
s.files += %w( src/core/lib/gprpp/single_set_ptr.h )
s.files += %w( src/core/lib/gprpp/sorted_pack.h )
s.files += %w( src/core/lib/gprpp/stat.h )
diff --git a/grpc.gyp b/grpc.gyp
index 6f78dddb3b0..6b74971bec3 100644
--- a/grpc.gyp
+++ b/grpc.gyp
@@ -795,6 +795,7 @@
'src/core/lib/experiments/experiments.cc',
'src/core/lib/gprpp/load_file.cc',
'src/core/lib/gprpp/per_cpu.cc',
+ 'src/core/lib/gprpp/ref_counted_string.cc',
'src/core/lib/gprpp/status_helper.cc',
'src/core/lib/gprpp/time.cc',
'src/core/lib/gprpp/time_averaged_stats.cc',
@@ -1301,6 +1302,7 @@
'src/core/lib/experiments/experiments.cc',
'src/core/lib/gprpp/load_file.cc',
'src/core/lib/gprpp/per_cpu.cc',
+ 'src/core/lib/gprpp/ref_counted_string.cc',
'src/core/lib/gprpp/status_helper.cc',
'src/core/lib/gprpp/time.cc',
'src/core/lib/gprpp/time_averaged_stats.cc',
@@ -2027,6 +2029,7 @@
'src/core/lib/experiments/experiments.cc',
'src/core/lib/gprpp/load_file.cc',
'src/core/lib/gprpp/per_cpu.cc',
+ 'src/core/lib/gprpp/ref_counted_string.cc',
'src/core/lib/gprpp/status_helper.cc',
'src/core/lib/gprpp/time.cc',
'src/core/lib/gprpp/time_averaged_stats.cc',
diff --git a/package.xml b/package.xml
index e96864b2a0d..d0788e58548 100644
--- a/package.xml
+++ b/package.xml
@@ -1227,6 +1227,8 @@
+
+
diff --git a/src/core/BUILD b/src/core/BUILD
index cba9d591d70..44458014cc0 100644
--- a/src/core/BUILD
+++ b/src/core/BUILD
@@ -960,6 +960,23 @@ grpc_cc_library(
],
)
+grpc_cc_library(
+ name = "ref_counted_string",
+ srcs = [
+ "lib/gprpp/ref_counted_string.cc",
+ ],
+ hdrs = [
+ "lib/gprpp/ref_counted_string.h",
+ ],
+ external_deps = ["absl/strings"],
+ language = "c++",
+ deps = [
+ "ref_counted",
+ "//:gpr",
+ "//:ref_counted_ptr",
+ ],
+)
+
grpc_cc_library(
name = "uuid_v4",
srcs = ["lib/gprpp/uuid_v4.cc"],
@@ -2680,6 +2697,7 @@ grpc_cc_library(
"channel_stack_type",
"dual_ref_counted",
"ref_counted",
+ "ref_counted_string",
"time",
"useful",
"//:channel_arg_names",
@@ -4499,6 +4517,7 @@ grpc_cc_library(
"lb_policy_factory",
"lb_policy_registry",
"pollset_set",
+ "ref_counted_string",
"validation_errors",
"//:channel_arg_names",
"//:config",
@@ -4653,6 +4672,7 @@ grpc_cc_library(
deps = [
"channel_args",
"ref_counted",
+ "ref_counted_string",
"//:gpr_platform",
"//:ref_counted_ptr",
"//:server_address",
diff --git a/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc b/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc
index 0ddaaf0f523..8dcc5f8d5c4 100644
--- a/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc
@@ -36,7 +36,7 @@ int HierarchicalPathArg::ChannelArgsCompare(const HierarchicalPathArg* a,
const HierarchicalPathArg* b) {
for (size_t i = 0; i < a->path_.size(); ++i) {
if (b->path_.size() == i) return 1;
- int r = a->path_[i].compare(b->path_[i]);
+ int r = a->path_[i].as_string_view().compare(b->path_[i].as_string_view());
if (r != 0) return r;
}
if (b->path_.size() > a->path_.size()) return -1;
@@ -47,19 +47,24 @@ absl::StatusOr MakeHierarchicalAddressMap(
const absl::StatusOr& addresses) {
if (!addresses.ok()) return addresses.status();
HierarchicalAddressMap result;
+ RefCountedPtr remaining_path_attr;
for (const ServerAddress& address : *addresses) {
const auto* path_arg = address.args().GetObject();
if (path_arg == nullptr) continue;
- const std::vector& path = path_arg->path();
+ const std::vector& path = path_arg->path();
auto it = path.begin();
if (it == path.end()) continue;
ServerAddressList& target_list = result[*it];
ChannelArgs args = address.args();
++it;
if (it != path.end()) {
- std::vector remaining_path(it, path.end());
- args = args.SetObject(
- MakeRefCounted(std::move(remaining_path)));
+ std::vector remaining_path(it, path.end());
+ if (remaining_path_attr == nullptr ||
+ remaining_path_attr->path() != remaining_path) {
+ remaining_path_attr =
+ MakeRefCounted(std::move(remaining_path));
+ }
+ args = args.SetObject(remaining_path_attr);
}
target_list.emplace_back(address.address(), args);
}
diff --git a/src/core/ext/filters/client_channel/lb_policy/address_filtering.h b/src/core/ext/filters/client_channel/lb_policy/address_filtering.h
index 2e4aa2017d4..b17c13bbb8c 100644
--- a/src/core/ext/filters/client_channel/lb_policy/address_filtering.h
+++ b/src/core/ext/filters/client_channel/lb_policy/address_filtering.h
@@ -20,7 +20,6 @@
#include
#include