luci-base: add urldecode() and urlencode() C implementations
authorJo-Philipp Wich <jo@mein.io>
Mon, 9 Apr 2018 07:47:40 +0000 (09:47 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 10 Apr 2018 09:41:32 +0000 (11:41 +0200)
commitad7dc4a4928e77ae142d0fe040f9e9e64b530e82
tree231c94708ba29b19386c608d6b9f34f3938fbbde
parentedd1fab34eaa98be624bbba17f60a8ae63744a98
luci-base: add urldecode() and urlencode() C implementations

The C implementations of urlencode and urldecode are considerably faster
than their current Lua counterparts.

On an AMD Geode system, the C variant is up to ten times faster when
decoding strings and up to four times faster when encoding them.

The functions are also designed to only allocate new strings when any
actual changes are required, otherwise they reuse the existing input
strings, reducing the overal memory usage somewhat.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/src/template_lualib.c
modules/luci-base/src/template_utils.c
modules/luci-base/src/template_utils.h