Skip to content

Commit

Permalink
use to-ascii array vs table on mobile
Browse files Browse the repository at this point in the history
Summary: The table is large while the array is small.

Reviewed By: luciang

Differential Revision: D27986020

fbshipit-source-id: b6896514408758c592e2b74d801e38f217163f61
  • Loading branch information
yfeldblum authored and facebook-github-bot committed May 2, 2021
1 parent ab79b85 commit 93d52d8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions folly/lang/ToAscii.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct to_ascii_array {
}
};
template <uint64_t Base, typename Alphabet>
alignas(hardware_constructive_interference_size)
alignas(kIsMobile ? sizeof(size_t) : hardware_constructive_interference_size)
typename to_ascii_array<Base, Alphabet>::data_type_ const
to_ascii_array<Base, Alphabet>::data =
to_ascii_array<Base, Alphabet>::data_();
Expand Down Expand Up @@ -262,10 +262,10 @@ FOLLY_ALWAYS_INLINE void to_ascii_with_basic(
// keep /, % together so a peephole optimization computes them together
auto const q = v / Base;
auto const r = v % Base;
out[pos] = xlate(r);
out[pos] = xlate(uint8_t(r));
v = q;
}
out[0] = xlate(v);
out[0] = xlate(uint8_t(v));
}
template <uint64_t Base, typename Alphabet>
FOLLY_ALWAYS_INLINE size_t to_ascii_with_basic(char* out, uint64_t v) {
Expand Down Expand Up @@ -380,8 +380,11 @@ inline size_t to_ascii_size_decimal(uint64_t v) {
template <uint64_t Base, typename Alphabet>
size_t to_ascii_with(char* outb, char const* oute, uint64_t v) {
auto const size = to_ascii_size<Base>(v);
return FOLLY_UNLIKELY(oute < outb || size_t(oute - outb) < size)
? 0
if (FOLLY_UNLIKELY(oute < outb || size_t(oute - outb) < size)) {
return 0;
}
return kIsMobile //
? detail::to_ascii_with_array<Base, Alphabet>(outb, v)
: detail::to_ascii_with_table<Base, Alphabet>(outb, v);
}
template <uint64_t Base, typename Alphabet, size_t N>
Expand Down

0 comments on commit 93d52d8

Please sign in to comment.