icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Utility::ValidateUTF8(): move a string instead of copying a vector

Open Al2Klimov opened this issue 3 years ago • 3 comments

less malloc() = more speed

Especially as JsonEncode() validates every single input string.

fixes #9506

Al2Klimov avatar Sep 07 '22 13:09 Al2Klimov

Unit tests ftw!

Al2Klimov avatar Sep 07 '22 14:09 Al2Klimov

The change is fine but there's more room for optimization. Typically, the function should do nothing as the string should usually only contain valid UTF-8. So in this case, no copy would be needed at all. But achieving this isn't really possible with the current signature, and would likely require touching all callers.

julianbrost avatar Sep 07 '22 15:09 julianbrost

So in this case, no copy would be needed at all. But achieving this isn't really possible with the current signature, and would likely require touching all callers.

I'm currently trying to achieve this!

yhabteab avatar Sep 07 '22 15:09 yhabteab