fix(color_util): Use lambda

This commit is contained in:
Michael Carlberg 2017-01-23 23:54:09 +01:00
parent 4558893c37
commit 6cc7a2c093
1 changed files with 3 additions and 7 deletions

View File

@ -58,9 +58,7 @@ namespace color_util {
template <typename T>
string hex(unsigned int color) {
string hex;
if (!g_cache_hex.check(color)) {
return *g_cache_hex.object(color, [&] {
char s[12];
size_t len = 0;
@ -75,10 +73,8 @@ namespace color_util {
len = snprintf(s, sizeof(s), "#%02x%02x%02x", r, g, b);
}
hex = string(s, len);
}
return *g_cache_hex.object(color, hex);
return string(s, len);
}());
}
inline string parse_hex(string hex) {