Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D65F118FFA for ; Tue, 24 Nov 2015 16:37:16 +0000 (UTC) Received: (qmail 67787 invoked by uid 500); 24 Nov 2015 16:37:11 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 67704 invoked by uid 500); 24 Nov 2015 16:37:11 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 67694 invoked by uid 99); 24 Nov 2015 16:37:11 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Nov 2015 16:37:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id D74D4C0FEA for ; Tue, 24 Nov 2015 16:37:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.101 X-Spam-Level: X-Spam-Status: No, score=-0.101 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id PhwDhnGE-4mF for ; Tue, 24 Nov 2015 16:37:05 +0000 (UTC) Received: from mail-qg0-f44.google.com (mail-qg0-f44.google.com [209.85.192.44]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 1E41220CF5 for ; Tue, 24 Nov 2015 16:37:05 +0000 (UTC) Received: by qgeb1 with SMTP id b1so14281578qge.1 for ; Tue, 24 Nov 2015 08:36:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=7HivE1AHBPjO+U2seWc/k8vF4fR7furu+yPJrLut0iA=; b=fjvDnJLyBWeLeTfLkyjhFuucj/sx2tYgUZbqCyb7II/awFQY6aXcakZn3m44xt8j2t hi/6VAJk9F6bvfUJeDq/rZZQEyV4+YUsCHWzVmn1ggYtpCbcsfzSCu5ms7Di2e3buXer l35/vC6C6nxS1OH6WC95zbq4IWGuiyx4DS+7ymPYf0T8gYPFWlxrbRPfCeUbIssFIgPg 60OghJAjtcDcXXtpqB7a7XCUd3xN9vDRBya1qvmDfT1Xa1gMFNuxXmgPAR3d0DOgFnuJ CLx2dzBM87eMGls+r1+ncTfKpjUyahSrEOE6mj4Sxuulbxh+C8GNbcBsbXwwC1JENTW5 1CGw== MIME-Version: 1.0 X-Received: by 10.140.95.66 with SMTP id h60mr34609502qge.14.1448383018623; Tue, 24 Nov 2015 08:36:58 -0800 (PST) Received: by 10.55.101.84 with HTTP; Tue, 24 Nov 2015 08:36:58 -0800 (PST) In-Reply-To: References: <20151123200516.D444B3A043E@svn01-us-west.apache.org> <3F16527F-A2FE-4CEE-A87C-E98BB6DF07ED@sharp.fm> Date: Tue, 24 Nov 2015 17:36:58 +0100 Message-ID: Subject: Re: svn commit: r1715938 - /httpd/httpd/trunk/modules/cache/cache_util.c From: Yann Ylavic To: httpd-dev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Nov 24, 2015 at 5:18 PM, Graham Leggett wrote: > On 24 Nov 2015, at 6:15 PM, Yann Ylavic wrote: > >> Not sure: >> if (!strcmp(h, "max-age") >> || ap_cmpcasestr(h, "max-age")) >> is likely to be a bit faster than a single ap_cmpcasestr() when it >> matches, but much slower when it does not. > > Yep, that=E2=80=99s the point. > > The vast majority of comparisons are lowercase for tokens like this. Migh= t as well test that fast path first before testing the worst case scenario. Sure, but my point is that the worst case is likely depend on the application, eg: case 'm': case 'M': if (!strncmp(token, "max-age", 7) || !ap_casecmpstrn(token, "max-age", 7)) { ... } else if (!strncmp(token, "max-stale", 9) || !ap_casecmpstrn(token, "max-stale", 9)) { ... } else if (!strncmp(token, "min-fresh", 9) || !ap_casecmpstrn(token, "min-fresh", 9)) { ... } else if (!strcmp(token, "max-revalidate") || !ap_casecmpstr(token, "must-revalidate")) { ... } else if ... is going to be costly when matched against "must-revalidate", or worse "my-token". We could use all str[n]cmp() first, but still it's a lot of comparisons, and now duplicated code too. Regards, Yann.