[Top][All Lists]

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

bug#31138: Native json slower than json.el

From: Alex Gramiak
Subject: bug#31138: Native json slower than json.el
Date: Mon, 22 Apr 2019 13:52:09 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> From: Alex Gramiak <address@hidden>
>> Cc: Eli Zaretskii <address@hidden>, Dmitry Gutov <address@hidden>
>> Date: Mon, 22 Apr 2019 12:20:15 -0600
>> P.S. Would applying the following diff be okay? It's a simple
>> optimization that avoids an overflow check (the sizeof comparison is
>> optimized out even in -O0)
> I don't understand what this optimizes, since AFAIU INT_TO_INTEGER
> already produces a fixnum if possible.

I was attempting to avoid the FIXNUM_OVERFLOW_P check that make_(u)int
does, but I wasn't taking into consideration that EMACS_INT can hold
non-fixnum values due to bits needed for the Lisp_Object tag. You can
disregard my previous diff. The following might work, though I'm not
sure how applicable this is now to the jansson library:

diff --git a/src/lisp.h b/src/lisp.h
index c2cb89de9d..c45e35178e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2661,8 +2661,10 @@ make_uint (uintmax_t n)
 /* Return a Lisp integer equal to the value of the C integer EXPR.  */
-#define INT_TO_INTEGER(expr) \
-  (EXPR_SIGNED (expr) ? make_int (expr) : make_uint (expr))
+#define INT_TO_INTEGER(expr)                                    \
+  (sizeof (expr) < sizeof (EMACS_INT)                           \
+   ? make_fixnum (expr)                                         \
+   : (EXPR_SIGNED (expr) ? make_int (expr) : make_uint (expr)))
 /* Forwarding pointer to an int variable.
The above assumes that INTTYPEBITS is less than 8, which I suppose could
be put in there as well as a sanity check.

> Not sure what you meant by "usual case".

I just meant the case where json_int_t does not have a greater size than

reply via email to

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