emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 1680a1c 2/2: Pass 'struct json_configuration' as const where poss


From: Philipp Stephani
Subject: master 1680a1c 2/2: Pass 'struct json_configuration' as const where possible.
Date: Sat, 13 Feb 2021 08:38:37 -0500 (EST)

branch: master
commit 1680a1c0945cb0aa7e0e16867a9dacb8316cbf33
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>

    Pass 'struct json_configuration' as const where possible.
    
    The JSON serialization and parsing functions don't need to modify
    these structures.
    
    * src/json.c (lisp_to_json_nonscalar_1, lisp_to_json_nonscalar)
    (lisp_to_json, json_to_lisp): Mark configuration object parameter as
    const.
---
 src/json.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/json.c b/src/json.c
index e0e49ae..3562e17 100644
--- a/src/json.c
+++ b/src/json.c
@@ -327,13 +327,14 @@ struct json_configuration {
   Lisp_Object false_object;
 };
 
-static json_t *lisp_to_json (Lisp_Object, struct json_configuration *conf);
+static json_t *lisp_to_json (Lisp_Object,
+                             const struct json_configuration *conf);
 
 /* Convert a Lisp object to a nonscalar JSON object (array or object).  */
 
 static json_t *
 lisp_to_json_nonscalar_1 (Lisp_Object lisp,
-                          struct json_configuration *conf)
+                          const struct json_configuration *conf)
 {
   json_t *json;
   ptrdiff_t count;
@@ -454,7 +455,7 @@ lisp_to_json_nonscalar_1 (Lisp_Object lisp,
 
 static json_t *
 lisp_to_json_nonscalar (Lisp_Object lisp,
-                        struct json_configuration *conf)
+                        const struct json_configuration *conf)
 {
   if (++lisp_eval_depth > max_lisp_eval_depth)
     xsignal0 (Qjson_object_too_deep);
@@ -468,7 +469,7 @@ lisp_to_json_nonscalar (Lisp_Object lisp,
    JSON object.  */
 
 static json_t *
-lisp_to_json (Lisp_Object lisp, struct json_configuration *conf)
+lisp_to_json (Lisp_Object lisp, const struct json_configuration *conf)
 {
   if (EQ (lisp, conf->null_object))
     return json_check (json_null ());
@@ -788,7 +789,7 @@ usage: (json-insert OBJECT &rest ARGS)  */)
 /* Convert a JSON object to a Lisp object.  */
 
 static Lisp_Object ARG_NONNULL ((1))
-json_to_lisp (json_t *json, struct json_configuration *conf)
+json_to_lisp (json_t *json, const struct json_configuration *conf)
 {
   switch (json_typeof (json))
     {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]