From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#31138: Native json slower than json.el Date: Mon, 22 Apr 2019 20:12:18 +0300 Message-ID: <83pnpe55hp.fsf@gnu.org> References: <87sh806xwa.fsf@chapu.is> <83zhphliil.fsf@gnu.org> <181b93a3-3861-0481-1b95-8344410d1049@yandex.ru> <83r2a2hdxn.fsf@gnu.org> <21f68973-a684-2a65-82eb-c8f3df90127f@yandex.ru> <83d0lmgez2.fsf@gnu.org> <7d503be9-4d85-3d0b-6829-631ad376ba3d@yandex.ru> <831s22gcci.fsf@gnu.org> <83y349gasn.fsf@gnu.org> <83d0lfag4x.fsf@gnu.org> <5cf45a21-65c3-67ee-f123-be83a6ee7c99@yandex.ru> <83a7gjaen6.fsf@gnu.org> <10ca4e2f-b116-16bc-c81e-24036752c867@yandex.ru> <83lg026xxb.fsf@gnu.org> <0d42dab4-6c5c-be3a-d402-f17b39e7fc3c@yandex.ru> <83k1fm6vly.fsf@gnu.org> <19b19dec-a5a0-e08d-6026-0b9621d38143@yandex.ru> <8336ma6oia.fsf@gnu.org> <83tveq56jr.fsf@gnu.org> Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="118001"; mail-complaints-to="usenet@blaine.gmane.org" Cc: p.stephani2@gmail.com, sebastien@chapu.is, yyoncho@gmail.com, 31138@debbugs.gnu.org To: dgutov@yandex.ru Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 22 19:23: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 1hIcf1-000UYV-Fo for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 19:23:19 +0200 Original-Received: from localhost ([127.0.0.1]:40389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIcf0-00039H-FD for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Apr 2019 13:23:18 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIccc-0001Ot-P7 for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 13:20:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hIcV7-0003Cj-PG for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 13:13:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hIcV4-0003At-IM for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 13:13:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hIcV4-0000bX-CX for bug-gnu-emacs@gnu.org; Mon, 22 Apr 2019 13:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Apr 2019 17:13: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.15559531682300 (code B ref 31138); Mon, 22 Apr 2019 17:13:02 +0000 Original-Received: (at 31138) by debbugs.gnu.org; 22 Apr 2019 17:12:48 +0000 Original-Received: from localhost ([127.0.0.1]:51501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIcUp-0000b1-Nw for submit@debbugs.gnu.org; Mon, 22 Apr 2019 13:12:48 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:33749) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hIcUo-0000ap-1g for 31138@debbugs.gnu.org; Mon, 22 Apr 2019 13:12:46 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:44427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hIcUY-0002pL-0u; Mon, 22 Apr 2019 13:12:31 -0400 Original-Received: from [176.228.60.248] (port=1892 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hIcUW-00065O-Rt; Mon, 22 Apr 2019 13:12:29 -0400 In-reply-to: <83tveq56jr.fsf@gnu.org> (message from Eli Zaretskii on Mon, 22 Apr 2019 19:49:28 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:158067 Archived-At: > Date: Mon, 22 Apr 2019 19:49:28 +0300 > From: Eli Zaretskii > Cc: p.stephani2@gmail.com, sebastien@chapu.is, yyoncho@gmail.com, > 31138@debbugs.gnu.org > > Btw, we could somewhat speed up even the case where we do call > code_convert_string, by avoiding the call to make_specified_string. Like this: diff --git a/src/json.c b/src/json.c index 16500bc..48aeccf 100644 --- a/src/json.c +++ b/src/json.c @@ -225,8 +225,12 @@ json_has_suffix (const char *string, const char *suffix) static Lisp_Object json_make_string (const char *data, ptrdiff_t size) { - return code_convert_string (make_specified_string (data, -1, size, false), - Qutf_8_unix, Qt, false, true, true); + struct coding_system coding; + setup_coding_system (Qutf_8_unix, &coding); + coding.mode |= CODING_MODE_LAST_BLOCK; + coding.source = data; + decode_coding_object (&coding, Qnil, 0, 0, size, size, Qt); + return coding.dst_object; } /* Create a multibyte Lisp string from the NUL-terminated UTF-8 How does this fare in your benchmarks?