Commit e929ede4 by Copybara-Service

Merge pull request #1472 from pateldeev:iv

PiperOrigin-RevId: 539145188
Change-Id: Ic8dc8112f77ca720a8871de57ee389f15693ab00
parents 2b042424 1524b1ac
...@@ -1169,6 +1169,7 @@ cc_library( ...@@ -1169,6 +1169,7 @@ cc_library(
":strings", ":strings",
"//absl/base:config", "//absl/base:config",
"//absl/base:core_headers", "//absl/base:core_headers",
"//absl/container:inlined_vector",
"//absl/functional:function_ref", "//absl/functional:function_ref",
"//absl/meta:type_traits", "//absl/meta:type_traits",
"//absl/numeric:bits", "//absl/numeric:bits",
......
...@@ -432,6 +432,7 @@ absl_cc_library( ...@@ -432,6 +432,7 @@ absl_cc_library(
absl::strings absl::strings
absl::config absl::config
absl::core_headers absl::core_headers
absl::inlined_vector
absl::numeric_representation absl::numeric_representation
absl::type_traits absl::type_traits
absl::utility absl::utility
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <string> #include <string>
#include "absl/base/port.h" #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/arg.h"
#include "absl/strings/internal/str_format/checker.h" #include "absl/strings/internal/str_format/checker.h"
#include "absl/strings/internal/str_format/parser.h" #include "absl/strings/internal/str_format/parser.h"
...@@ -177,17 +178,7 @@ class Streamable { ...@@ -177,17 +178,7 @@ class Streamable {
public: public:
Streamable(const UntypedFormatSpecImpl& format, Streamable(const UntypedFormatSpecImpl& format,
absl::Span<const FormatArgImpl> args) absl::Span<const FormatArgImpl> args)
: format_(format) { : format_(format), args_(args.begin(), args.end()) {}
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_;
}
}
std::ostream& Print(std::ostream& os) const; std::ostream& Print(std::ostream& os) const;
...@@ -197,12 +188,7 @@ class Streamable { ...@@ -197,12 +188,7 @@ class Streamable {
private: private:
const UntypedFormatSpecImpl& format_; const UntypedFormatSpecImpl& format_;
absl::Span<const FormatArgImpl> args_; absl::InlinedVector<FormatArgImpl, 4> 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_;
}; };
// for testing // for testing
...@@ -211,8 +197,7 @@ std::string Summarize(UntypedFormatSpecImpl format, ...@@ -211,8 +197,7 @@ std::string Summarize(UntypedFormatSpecImpl format,
bool BindWithPack(const UnboundConversion* props, bool BindWithPack(const UnboundConversion* props,
absl::Span<const FormatArgImpl> pack, BoundConversion* bound); absl::Span<const FormatArgImpl> pack, BoundConversion* bound);
bool FormatUntyped(FormatRawSinkImpl raw_sink, bool FormatUntyped(FormatRawSinkImpl raw_sink, UntypedFormatSpecImpl format,
UntypedFormatSpecImpl format,
absl::Span<const FormatArgImpl> args); absl::Span<const FormatArgImpl> args);
std::string& AppendPack(std::string* out, UntypedFormatSpecImpl format, std::string& AppendPack(std::string* out, UntypedFormatSpecImpl format,
...@@ -231,7 +216,7 @@ int SnprintF(char* output, size_t size, UntypedFormatSpecImpl format, ...@@ -231,7 +216,7 @@ int SnprintF(char* output, size_t size, UntypedFormatSpecImpl format,
template <typename T> template <typename T>
class StreamedWrapper { class StreamedWrapper {
public: public:
explicit StreamedWrapper(const T& v) : v_(v) { } explicit StreamedWrapper(const T& v) : v_(v) {}
private: private:
template <typename S> template <typename S>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment