fix(color_util): Use lambda
This commit is contained in:
parent
4558893c37
commit
6cc7a2c093
@ -58,9 +58,7 @@ namespace color_util {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
string hex(unsigned int color) {
|
string hex(unsigned int color) {
|
||||||
string hex;
|
return *g_cache_hex.object(color, [&] {
|
||||||
|
|
||||||
if (!g_cache_hex.check(color)) {
|
|
||||||
char s[12];
|
char s[12];
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
@ -75,10 +73,8 @@ namespace color_util {
|
|||||||
len = snprintf(s, sizeof(s), "#%02x%02x%02x", r, g, b);
|
len = snprintf(s, sizeof(s), "#%02x%02x%02x", r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
hex = string(s, len);
|
return string(s, len);
|
||||||
}
|
}());
|
||||||
|
|
||||||
return *g_cache_hex.object(color, hex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline string parse_hex(string hex) {
|
inline string parse_hex(string hex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user