mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 10:40:00 +08:00
Improve unicode codepoint Bisearch performance (#691)
Improve the performance of the functions for searching for codepoints in a table by passing the table array in as a reference instead of copying it. Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
parent
2bcdb9ac54
commit
de6749fed7
@ -29,6 +29,19 @@ static void BencharkBasic(benchmark::State& state) {
|
|||||||
}
|
}
|
||||||
BENCHMARK(BencharkBasic)->DenseRange(0, 256, 16);
|
BENCHMARK(BencharkBasic)->DenseRange(0, 256, 16);
|
||||||
|
|
||||||
|
static void BencharkText(benchmark::State& state) {
|
||||||
|
while (state.KeepRunning()) {
|
||||||
|
std::string content = "HELLO world ";
|
||||||
|
for(int i=0; i<state.range(0); ++i) {
|
||||||
|
content += content;
|
||||||
|
}
|
||||||
|
auto document = paragraph(content);
|
||||||
|
Screen screen(200,200);
|
||||||
|
Render(screen, document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BENCHMARK(BencharkText)->DenseRange(0, 10, 1);
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
|
||||||
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
||||||
|
@ -1480,7 +1480,7 @@ const std::array<WordBreakPropertyInterval, 1288> g_word_break_intervals = {{
|
|||||||
|
|
||||||
// Find a codepoint inside a sorted list of Interval.
|
// Find a codepoint inside a sorted list of Interval.
|
||||||
template <size_t N>
|
template <size_t N>
|
||||||
bool Bisearch(uint32_t ucs, const std::array<Interval, N> table) {
|
bool Bisearch(uint32_t ucs, const std::array<Interval, N>& table) {
|
||||||
if (ucs < table.front().first || ucs > table.back().last) { // NOLINT
|
if (ucs < table.front().first || ucs > table.back().last) { // NOLINT
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1503,7 +1503,7 @@ bool Bisearch(uint32_t ucs, const std::array<Interval, N> table) {
|
|||||||
|
|
||||||
// Find a value inside a sorted list of Interval + property.
|
// Find a value inside a sorted list of Interval + property.
|
||||||
template <class C, size_t N>
|
template <class C, size_t N>
|
||||||
bool Bisearch(uint32_t ucs, const std::array<C, N> table, C* out) {
|
bool Bisearch(uint32_t ucs, const std::array<C, N>& table, C* out) {
|
||||||
if (ucs < table.front().first || ucs > table.back().last) { // NOLINT
|
if (ucs < table.front().first || ucs > table.back().last) { // NOLINT
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user