From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.bugs Subject: bug#31138: Native json slower than json.el Date: Mon, 22 Apr 2019 12:20:15 -0600 Message-ID: <87ftq96gww.fsf@gmail.com> References: <87sh806xwa.fsf@chapu.is> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="126612"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: Dmitry Gutov To: 31138@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 22 20:21:20 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hIdZ2-000WgR-UM for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 20:21:18 +0200 Original-Received: from localhost ([127.0.0.1]:40989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIdZ1-0006rl-O1 for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 14:21:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIdYu-0006rc-KI for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 14:21:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIdYs-0005nW-Pc for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 14:21:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIdYs-0005n5-Lw for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 14:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIdYs-0002Gw-Ao for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 14:21:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87sh806xwa.fsf@chapu.is> Resent-From: Alex Gramiak Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2019 18:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31138 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 31138-submit@debbugs.gnu.org id=B31138.15559572288654 (code B ref 31138); Mon, 22 Apr 2019 18:21:02 +0000 Original-Received: (at 31138) by debbugs.gnu.org; 22 Apr 2019 18:20:28 +0000 Original-Received: from localhost ([127.0.0.1]:51578 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIdYJ-0002FV-QQ for submit@debbugs.gnu.org; Mon, 22 Apr 2019 14:20:28 -0400 Original-Received: from mail-pf1-f174.google.com ([209.85.210.174]:44083) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIdYG-0002FH-E6 for 31138@debbugs.gnu.org; Mon, 22 Apr 2019 14:20:24 -0400 Original-Received: by mail-pf1-f174.google.com with SMTP id y13so6075653pfm.11 for <31138@debbugs.gnu.org>; Mon, 22 Apr 2019 11:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:user-agent:mime-version; bh=dJnUItwkpWyb26ifaW60XZVmNIrEITEi4+ngAnn8P9s=; b=hhlm7Ly89Fex7GkYfn2yWE3wz6LP4wukQGath7qoYliwSYQhDDiTBS2Y833sjxvvME L5DWK0SUlx+pplsvR7pH9hsjfaEU5jVJjYiwimijVRcufpJEb/ag4Cozfw7v5bGnkQ/6 15QStdLJoFebVU9Ty44JInwu526CWmor8F/VMXkWxOfnWceuqYXFGaZmkJPo6rTXHqqx CkN+/dQYrCEvFMCuM91k5rryoC2VsqmrjsO5H7CYtOGGAcw8QFSLlTNKyEEVmXwPfzSp 0qiP7hh7OMXmyo0yt2YXjBPz/AvljnoVSrifpC3/qpUjJs+TSY3moS6pszoAevnHE4T/ rOtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version; bh=dJnUItwkpWyb26ifaW60XZVmNIrEITEi4+ngAnn8P9s=; b=tKdQxUm2sMZnZHg1Z8s8oapLK5ZyhYQg2VvcIKTGPCsfz88bxFTeXlcYeF1CFaeyS4 Zx+yYv6dXr/kU06QMeh2Wo0Sj3koiM2dWk0xUqYQQGSwL16sZmMtWbRtalxpq8QyFUlA pEB0lJrLIkcIoCGZ/VcL5HK0vPD8kuF2/GG82TRDiFY/DPhwOCRtVNNOx2KPdZYtN/+V FmSO5j7dc6VCPkSo7Kr2objB0hG7vgCw431YkzSSnxqVQCbFFg1C62cu8wA3Ng4xHvZn snaQSwYQwcePoZc0WjQ3HgaBhBd4V+daItjns50Y2sHrXMEnkeJf8geGydVf/gghbTxd /XGQ== X-Gm-Message-State: APjAAAVhRoZFWvzQjkLnFiB82MjMv/unqvES2KrcQHkW+5JyJC52dA0j 2bToGS9wh3whVdJEklDm6ug= X-Google-Smtp-Source: APXvYqwVXzdtJumRAmdWCq+kLWebn6FZ3kO8npPoqTQwr06OqBdPUdXcqUzN1N2ZIwQSufHBWkHSjg== X-Received: by 2002:a63:4144:: with SMTP id o65mr20202565pga.241.1555957218632; Mon, 22 Apr 2019 11:20:18 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id e16sm243742pgv.89.2019.04.22.11.20.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2019 11:20:17 -0700 (PDT) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158070 Archived-At: --=-=-= Content-Type: text/plain If the validation is done on the Emacs side, then perhaps it would be beneficial to use the json_*_nocheck function alternatives to disable libjannson's validation, namely json_stringn_nocheck and json_object_set_new_nocheck. [1] jansson.readthedocs.io/en/stable/apiref.html#c.json_stringn_nocheck 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) in the usual case of a JSON integer fitting into an EMACS_INT. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=sizeof.diff Content-Description: sizeof diff --git a/src/json.c b/src/json.c index 928825e034..9faf1f80ca 100644 --- a/src/json.c +++ b/src/json.c @@ -836,7 +836,10 @@ json_to_lisp (json_t *json, struct json_configuration *conf) case JSON_INTEGER: { json_int_t i = json_integer_value (json); - return INT_TO_INTEGER (i); + if (sizeof (json_int_t) <= sizeof (EMACS_INT)) + return make_fixnum (i); + else + return INT_TO_INTEGER (i); } case JSON_REAL: return make_float (json_real_value (json)); --=-=-=--