From dd7a711244e3d33e3e960cd990e9afccc6877820 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 9 Jun 2020 15:41:45 +0100 Subject: json-parser: Support loading files via memory mapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- json-glib/json-parser.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'json-glib/json-parser.h') 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, -- cgit v1.2.1