diff options
author | Copybara-Service <copybara-worker@google.com> | 2023-06-09 12:11:45 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-06-09 12:11:45 -0700 |
commit | e929ede4112cc21a5173578c88317c3f4c8e71cc (patch) | |
tree | bd416dbbe3792651fd32a97938b7fb43b4229fbd /absl/strings/internal | |
parent | 2b042424db44e9614d3c100832dff1a54f37b351 (diff) | |
parent | 1524b1ac07c77f8c58e18a828b7efb92ff7a660e (diff) |
Merge pull request #1472 from pateldeev:iv
PiperOrigin-RevId: 539145188
Change-Id: Ic8dc8112f77ca720a8871de57ee389f15693ab00
Diffstat (limited to 'absl/strings/internal')
-rw-r--r-- | absl/strings/internal/str_format/bind.h | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/absl/strings/internal/str_format/bind.h b/absl/strings/internal/str_format/bind.h index b73c5028..5e2a43d5 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 @@ -211,8 +197,7 @@ std::string Summarize(UntypedFormatSpecImpl format, bool BindWithPack(const UnboundConversion* props, absl::Span<const FormatArgImpl> pack, BoundConversion* bound); -bool FormatUntyped(FormatRawSinkImpl raw_sink, - UntypedFormatSpecImpl format, +bool FormatUntyped(FormatRawSinkImpl raw_sink, UntypedFormatSpecImpl format, absl::Span<const FormatArgImpl> args); std::string& AppendPack(std::string* out, UntypedFormatSpecImpl format, @@ -231,7 +216,7 @@ int SnprintF(char* output, size_t size, UntypedFormatSpecImpl format, template <typename T> class StreamedWrapper { public: - explicit StreamedWrapper(const T& v) : v_(v) { } + explicit StreamedWrapper(const T& v) : v_(v) {} private: template <typename S> |