Merge pull request #104389 from Ivorforce/color-string-append
Optimize `Color::to_html` by allocating less.
This commit is contained in:
@@ -36,6 +36,9 @@
|
||||
|
||||
#include <iterator>
|
||||
|
||||
static constexpr char hex_char_table_upper[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
static constexpr char hex_char_table_lower[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
|
||||
|
||||
#define BSEARCH_CHAR_RANGE(m_array) \
|
||||
int low = 0; \
|
||||
int high = std::size(m_array) - 1; \
|
||||
|
||||
@@ -4729,9 +4729,8 @@ String String::uri_encode() const {
|
||||
res += ord;
|
||||
} else {
|
||||
char p[4] = { '%', 0, 0, 0 };
|
||||
static const char hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
p[1] = hex[ord >> 4];
|
||||
p[2] = hex[ord & 0xF];
|
||||
p[1] = hex_char_table_upper[ord >> 4];
|
||||
p[2] = hex_char_table_upper[ord & 0xF];
|
||||
res += p;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user