diff options
author | Philip Withnall <withnall@endlessm.com> | 2020-06-09 15:41:45 +0100 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2020-06-09 15:43:04 +0100 |
commit | dd7a711244e3d33e3e960cd990e9afccc6877820 (patch) | |
tree | 6cdd86fb2578dee5f5626091cdcbd78a6c45df0a /json-glib/json-parser.h | |
parent | 13142637c8132f49e1bd012786eb5f7f7c6dc986 (diff) | |
download | json-glib-dd7a711244e3d33e3e960cd990e9afccc6877820.tar.gz |
json-parser: Support loading files via memory mapping
Add a new `json_parser_load_from_mapped_file()` to load JSON from
files via memory mapping. It’s otherwise similar to
`json_parser_load_from_file()`. It’s in the right position to be able
to memory map the file it’s reading from: it reads the input once
before building a `JsonNode` structure to represent it, doesn’t write
to the file, and often deals with large input files.
This should speed things up slightly due to reducing time spent
allocating a large chunk of heap memory to load the file into, if a
caller can support that.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Diffstat (limited to 'json-glib/json-parser.h')
-rw-r--r-- | json-glib/json-parser.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/json-glib/json-parser.h b/json-glib/json-parser.h index 1470fbf..91fde66 100644 --- a/json-glib/json-parser.h +++ b/json-glib/json-parser.h @@ -153,6 +153,10 @@ JSON_AVAILABLE_IN_1_0 gboolean json_parser_load_from_file (JsonParser *parser, const gchar *filename, GError **error); +JSON_AVAILABLE_IN_1_6 +gboolean json_parser_load_from_mapped_file (JsonParser *parser, + const gchar *filename, + GError **error); JSON_AVAILABLE_IN_1_0 gboolean json_parser_load_from_data (JsonParser *parser, const gchar *data, |