summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar pateldeev <pateldeev@nevada.unr.edu>2023-06-08 20:51:33 -0700
committerGravatar pateldeev <pateldeev@nevada.unr.edu>2023-06-08 20:53:28 -0700
commit1524b1ac07c77f8c58e18a828b7efb92ff7a660e (patch)
treec499a87ef6b04287952451e3c5603f4e99f42af7
parentafc9206b3d55b1f21790c536e0a3a4fc0b57f68f (diff)
Use InlinedVector
-rw-r--r--absl/strings/BUILD.bazel1
-rw-r--r--absl/strings/internal/str_format/bind.h20
2 files changed, 4 insertions, 17 deletions
diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel
index 4a111b5a..313ba1ab 100644
--- a/absl/strings/BUILD.bazel
+++ b/absl/strings/BUILD.bazel
@@ -1169,6 +1169,7 @@ cc_library(
":strings",
"//absl/base:config",
"//absl/base:core_headers",
+ "//absl/container:inlined_vector",
"//absl/functional:function_ref",
"//absl/meta:type_traits",
"//absl/numeric:bits",
diff --git a/absl/strings/internal/str_format/bind.h b/absl/strings/internal/str_format/bind.h
index b73c5028..4424c4b0 100644
--- a/absl/strings/internal/str_format/bind.h
+++ b/absl/strings/internal/str_format/bind.h
@@ -21,6 +21,7 @@
#include <string>
#include "absl/base/port.h"
+#include "absl/container/inlined_vector.h"
#include "absl/strings/internal/str_format/arg.h"
#include "absl/strings/internal/str_format/checker.h"
#include "absl/strings/internal/str_format/parser.h"
@@ -177,17 +178,7 @@ class Streamable {
public:
Streamable(const UntypedFormatSpecImpl& format,
absl::Span<const FormatArgImpl> args)
- : format_(format) {
- if (args.size() <= ABSL_ARRAYSIZE(few_args_)) {
- for (size_t i = 0; i < args.size(); ++i) {
- few_args_[i] = args[i];
- }
- args_ = absl::MakeSpan(few_args_, args.size());
- } else {
- many_args_.assign(args.begin(), args.end());
- args_ = many_args_;
- }
- }
+ : format_(format), args_(args.begin(), args.end()) { }
std::ostream& Print(std::ostream& os) const;
@@ -197,12 +188,7 @@ class Streamable {
private:
const UntypedFormatSpecImpl& format_;
- absl::Span<const FormatArgImpl> args_;
- // if args_.size() is 4 or less:
- FormatArgImpl few_args_[4] = {FormatArgImpl(0), FormatArgImpl(0),
- FormatArgImpl(0), FormatArgImpl(0)};
- // if args_.size() is more than 4:
- std::vector<FormatArgImpl> many_args_;
+ absl::InlinedVector<FormatArgImpl, 4> args_;
};
// for testing