Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29732 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41633 invoked by uid 1010); 25 May 2007 00:02:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 41618 invoked from network); 25 May 2007 00:02:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2007 00:02:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain prohost.org from 64.233.166.183 cause and error) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 64.233.166.183 py-out-1112.google.com Linux 2.4/2.6 Received: from [64.233.166.183] ([64.233.166.183:4036] helo=py-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/AF-57693-1A726564 for ; Thu, 24 May 2007 20:02:43 -0400 Received: by py-out-1112.google.com with SMTP id a25so493061pyi for ; Thu, 24 May 2007 17:02:38 -0700 (PDT) Received: by 10.64.21.6 with SMTP id 6mr4545788qbu.1180051358387; Thu, 24 May 2007 17:02:38 -0700 (PDT) Received: from ?192.168.1.110? ( [99.246.70.178]) by mx.google.com with ESMTP id f13sm4611406qba.2007.05.24.17.02.37; Thu, 24 May 2007 17:02:38 -0700 (PDT) In-Reply-To: <717e56840705241650p3210b76do1e1a0ae28e7aad3d@mail.gmail.com> References: <717e56840705241650p3210b76do1e1a0ae28e7aad3d@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: <696FDA78-D174-4BBA-9427-EAE8C24542DE@prohost.org> Cc: internals@lists.php.net Content-Transfer-Encoding: 7bit Date: Thu, 24 May 2007 20:02:33 -0400 To: Martin Majlis X-Mailer: Apple Mail (2.752.3) Subject: Re: [PHP-DEV] [PATCH] JSON_parser From: ilia@prohost.org (Ilia Alshanetsky) I think the current code is better and not to mention faster. Shorter code in this case does not mean better code. On 24-May-07, at 7:50 PM, 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; > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Ilia Alshanetsky