MCPcopy Create free account
hub / github.com/apache/arrow / ExactCapacity

Function ExactCapacity

cpp/src/gandiva/tests/string_ops_benchmark.cc:80–94  ·  view source on GitHub ↗

Exact output size, so the "old" arm gets a buffer large enough to complete.

Source from the content-addressed store, hash-verified

78
79// Exact output size, so the "old" arm gets a buffer large enough to complete.
80int32_t ExactCapacity(const std::string& text, const char* from, int flen, int olen) {
81 int64_t matches = 0;
82 auto tlen = static_cast<int32_t>(text.size());
83 if (flen > 0 && flen <= tlen) {
84 for (int32_t i = 0; i <= tlen - flen;) {
85 if (memcmp(text.data() + i, from, flen) == 0) {
86 ++matches;
87 i += flen;
88 } else {
89 ++i;
90 }
91 }
92 }
93 return static_cast<int32_t>(tlen + matches * (olen - flen));
94}
95
96void BM_ReplaceNew(benchmark::State& state) {
97 const ReplaceCase& c = Cases()[state.range(0)];

Callers 1

BM_ReplaceOldFunction · 0.85

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected