Skip to content

Commit 9095dfa

Browse files
authored
firestore(chore): ordered_code.cc: remove usage of absl internal function STLStringResizeUninitialized (#15889)
1 parent bfd796a commit 9095dfa

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

Firestore/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Unreleased
2+
- [changed] Minor refactor to avoid using an absl internal function. (#15889)
3+
14
# 12.10.0
25
- [feature] Added support for `regexFind` and `regexFindAll` Pipeline expressions.
36

Firestore/core/src/util/ordered_code.cc

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -375,22 +375,6 @@ static inline unsigned int OrderedNumLength(uint64_t val) {
375375
return static_cast<unsigned int>(lg + 1 + 7) / 8;
376376
}
377377

378-
// Append n bytes from src to *dst.
379-
// REQUIRES: n <= 9
380-
// REQUIRES: src[0..8] are readable bytes (even if n is smaller)
381-
//
382-
// If we use string::append() instead of this routine, it increases the
383-
// runtime of WriteNumIncreasingSmall/WriteNumDecreasingSmall from ~7ns to
384-
// ~13ns.
385-
static inline void AppendUpto9(std::string* dst,
386-
const char* src,
387-
unsigned int n) {
388-
const size_t old_size = dst->size();
389-
absl::strings_internal::STLStringResizeUninitialized(dst, old_size + 9);
390-
memcpy(&(*dst)[old_size], src, 9);
391-
dst->erase(old_size + n);
392-
}
393-
394378
void OrderedCode::WriteNumIncreasing(std::string* dest, uint64_t num) {
395379
// Values are encoded with a single byte length prefix, followed
396380
// by the actual value in big-endian format with leading 0 bytes
@@ -406,7 +390,7 @@ void OrderedCode::WriteNumIncreasing(std::string* dest, uint64_t num) {
406390
const unsigned int length = OrderedNumLength(num);
407391
char* start = buf + 9 - length - 1;
408392
*start = static_cast<char>(length);
409-
AppendUpto9(dest, start, length + 1);
393+
dest->append(start, length + 1);
410394
}
411395

412396
void OrderedCode::WriteNumDecreasing(std::string* dest, uint64_t num) {
@@ -424,7 +408,7 @@ void OrderedCode::WriteNumDecreasing(std::string* dest, uint64_t num) {
424408
const unsigned int length = OrderedNumLength(num);
425409
char* start = buf + 9 - length - 1;
426410
*start = static_cast<char>(~length);
427-
AppendUpto9(dest, start, length + 1);
411+
dest->append(start, length + 1);
428412
}
429413

430414
template <bool INVERT>

0 commit comments

Comments
 (0)