aboutsummaryrefslogtreecommitdiff
path: root/src/cjson/fpconv.c
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-09-23 13:39:47 -0400
committerMichael Lingelbach <m.j.lbach@gmail.com>2021-09-26 00:35:55 -0700
commit30fed27241cc2a8f930212375f994a7fa6c99008 (patch)
tree37e5ebc68bfbc835021640fda72be82c0074506d /src/cjson/fpconv.c
parent8decc9f52d7dbd8eeed3afdf86f800b3677d25ab (diff)
downloadrneovim-30fed27241cc2a8f930212375f994a7fa6c99008.tar.gz
rneovim-30fed27241cc2a8f930212375f994a7fa6c99008.tar.bz2
rneovim-30fed27241cc2a8f930212375f994a7fa6c99008.zip
feat(lua): expose lua-cjson as vim.json
* add vim.json.encode and vim.json.decode * use vim.NIL instead of cjson.null * resolve strict-prototypes warnings * The following benchmark shows an approximately 2.5x (750 ms vs 300 ms) improvement in deserialization performance over vim.fn.json_decode on a medium package.json ```lua local uv = vim.loop local function readfile(path) return end local json_url = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/b24c8d5c89ee93d1172b4127564f5da3b0c88dad/editors/code/package.json" io.popen(string.format('curl -v -f -L -O %q &> /dev/null', json_url)) local json_string = io.open('package.json'):read '*a' uv.update_time() local start = uv.hrtime() for i = 1,1000 do vim.fn.json_decode(json_string) end uv.update_time() print(string.format("Deserialization time vim.fn.json_decode: %s ms", (uv.hrtime() - start) * (1e-6))) uv.update_time() local start = uv.hrtime() for i = 1,1000 do vim.json.decode(json_string) end uv.update_time() print(string.format("Deserialization time vim.json.decode: %s ms", (uv.hrtime() - start) * (1e-6))) ``` Co-Authored-By: Björn Linse <bjorn.linse@gmail.com>
Diffstat (limited to 'src/cjson/fpconv.c')
-rw-r--r--src/cjson/fpconv.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cjson/fpconv.c b/src/cjson/fpconv.c
index 3e480ece0a..b2f7a214c2 100644
--- a/src/cjson/fpconv.c
+++ b/src/cjson/fpconv.c
@@ -55,7 +55,7 @@ static char locale_decimal_point = '.';
* localconv() may not be thread safe (=>crash), and nl_langinfo() is
* not supported on some platforms. Use sprintf() instead - if the
* locale does change, at least Lua CJSON won't crash. */
-static void fpconv_update_locale()
+static void fpconv_update_locale(void)
{
char buf[8];