Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29743 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5363 invoked by uid 1010); 25 May 2007 08:41:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 5348 invoked from network); 25 May 2007 08:41:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2007 08:41:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=martin.majlis@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=martin.majlis@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.162.227 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martin.majlis@gmail.com X-Host-Fingerprint: 64.233.162.227 nz-out-0506.google.com Linux 2.4/2.6 Received: from [64.233.162.227] ([64.233.162.227:6729] helo=nz-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3E/A3-11471-821A6564 for ; Fri, 25 May 2007 04:41:13 -0400 Received: by nz-out-0506.google.com with SMTP id 34so311314nzf for ; Fri, 25 May 2007 01:41:10 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=ez4YjYaoumrqxSbNAGOpD+W+3u8jtGby4QgWWPV30/dSXQ7TBtuQgk5420g2y+52IO2E9eh9OoTIixm9cmrap6A3rESixKynHiUTXmNyPpXOX0cxjRi8oLa+X4jsLb8wJG/XS/hNUlkVf3S03FiP5Wo95JvNfsko80bovKblXbw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=XLhZ4IboFb1hbkBrrc+DLnyVIRDkImXYkmbq13cwVBeuGo4u0+XF6+2Gd4h6Fp1aJJEtXxtcoJ3RFIMH8MDIHnmunSrWYL0+8y4Kj3P4Npe7627wILNg78Ja2oOd0Nu8qX8bZEF9A1ioAQHm4UzIBejsubQlC3vR0IPBMqu53p4= Received: by 10.114.12.9 with SMTP id 9mr1404311wal.1180082465858; Fri, 25 May 2007 01:41:05 -0700 (PDT) Received: by 10.115.16.13 with HTTP; Fri, 25 May 2007 01:41:05 -0700 (PDT) Message-ID: <717e56840705250141n86c2d04t212b81159e207de8@mail.gmail.com> Date: Fri, 25 May 2007 10:41:05 +0200 Sender: martin.majlis@gmail.com To: internals@lists.php.net In-Reply-To: <717e56840705241650p3210b76do1e1a0ae28e7aad3d@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <717e56840705241650p3210b76do1e1a0ae28e7aad3d@mail.gmail.com> X-Google-Sender-Auth: e770394338d0a309 Subject: Re: [PATCH] JSON_parser From: martin@m-core.net ("Martin Majlis") I make some small test. http://martin.m-core.net/misc/php/dehex.c - source code cc dehex.c; for i in `seq 1 1000`; do ./a.out >> dehex.log; done http://martin.m-core.net/misc/php/dehex.log - results I ignore values greater than 4e9. And here is summary: http://martin.m-core.net/misc/php/dehex.php Source of PHP script: http://martin.m-core.net/misc/php/dehex.phps So, m1 is very slow, but other ones are faster. Martin Majlis On 25/05/07, Martin Majlis wrote: > Just small refactoring. Replacing self-made function with functions > from standard headers. > > Index: JSON_parser.c > =================================================================== > RCS file: /repository/php-src/ext/json/JSON_parser.c,v > retrieving revision 1.1.2.8 > diff -u -u -r1.1.2.8 JSON_parser.c > --- JSON_parser.c 24 May 2007 22:37:59 -0000 1.1.2.8 > +++ JSON_parser.c 24 May 2007 23:41:11 -0000 > @@ -29,6 +29,8 @@ > > #include "JSON_parser.h" > #include > +#include > +#include > > #define true 1 > #define false 0 > @@ -259,18 +261,10 @@ > > static int dehexchar(char c) > { > - if (c >= '0' && c <= '9') > - { > - return c - '0'; > - } > - else if (c >= 'A' && c <= 'F') > - { > - return c - ('A' - 10); > - } > - else if (c >= 'a' && c <= 'f') > - { > - return c - ('a' - 10); > - } > + if (isxdigit(c)) > + { > + return strtol(&c, NULL, 16); > + } > else > { > return -1; >