From patchwork Thu Jun 27 23:39:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 11020837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41C711908 for ; Thu, 27 Jun 2019 23:39:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36BB928723 for ; Thu, 27 Jun 2019 23:39:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B5432872E; Thu, 27 Jun 2019 23:39:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F5AD28723 for ; Thu, 27 Jun 2019 23:39:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726772AbfF0Xjb (ORCPT ); Thu, 27 Jun 2019 19:39:31 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34136 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbfF0Xja (ORCPT ); Thu, 27 Jun 2019 19:39:30 -0400 Received: by mail-wr1-f67.google.com with SMTP id k11so4347622wrl.1 for ; Thu, 27 Jun 2019 16:39:28 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=bUiqybTOopFcwW4EfTGYqjTSRi5yZxqzQZSqNSqKeew=; b=LSxxHsfxEwlge5r2/28O3+qZpWPzj7RWIAlQrzFri4mPN5auhphy+8KHAGf78Bb4CF pGgCRkpWl9uRBR5c0hWsJ5ncFbBVAL/e37VEyDEv26IBPAmsDgqdUl/hm0V+kz7DEVJ0 4Ma5Yk7+EDkCNI9hsbNKoDRBwI1SenhLin1L3jo64UokpJI/G1kz31og+rb3EigGrw2s Z9GcQv+Cvg3Z2xyWxOq/Lhuay0xAt7+7bcHqRfL3ulYIVMxZHSgaqliV2tZRlW+1FKz/ XoaStWciIGoqG4/unT6tNCA6WkCeUkxJaOwHOvcXnH7RZY2iIeOFKcjpZrS4mk0uMmFE hTnA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=bUiqybTOopFcwW4EfTGYqjTSRi5yZxqzQZSqNSqKeew=; b=X2oQGAdEAwdZNQqzK0bA9KYpN/RnL84BluAPAJVytlLWuyDBnVlSmTWqTtZX2atxk1 90oNCnvwYG1Rqea7eEZN/edz2Si3bNqU0rIsuI3P9ZxzFKtgkEwVi5u9AAt6dcuvNY6k BvE2vmxZxarUSCRRSip7uMKpaquP8qNlsRBSgld13MtmtgRppF3sVDodf456bYDORGt7 Rdg2TFalwOAXN+9du4WckQIJ3EyUyjmgXEUkrqlW9lHn5wm3gfxyi2sGhPsbDcAlKZiD SYobNHn/kmtM1k939eC7hB53ZoqI28XIHKciNMIyGvlAPdqJe/hNJn2U6PKZ2kcLa6xB I6fg== X-Gm-Message-State: APjAAAVRV/Y6eaSuF+YOYuApqGLVeePjpPqbyIdYlpkUi/H3lrXLgSLn jRZ6nrp6Y5raIGH8mhvhoMZNLtFT X-Google-Smtp-Source: APXvYqwNQSAil4vq99j054PNy14hbXlv/Z3maqG7D8b7WByHg/KsZzZf9aGSL9mixxfsLnn3+KUqPQ== X-Received: by 2002:a5d:53c2:: with SMTP id a2mr5281259wrw.8.1561678767491; Thu, 27 Jun 2019 16:39:27 -0700 (PDT) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id x16sm720530wmj.4.2019.06.27.16.39.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 16:39:26 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: git-packagers@googlegroups.com, gitgitgadget@gmail.com, gitster@pobox.com, johannes.schindelin@gmx.de, peff@peff.net, sandals@crustytoothpaste.net, szeder.dev@gmail.com, =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH v2 3/9] grep: inline the return value of a function call used only once Date: Fri, 28 Jun 2019 01:39:06 +0200 Message-Id: <20190627233912.7117-4-avarab@gmail.com> X-Mailer: git-send-email 2.22.0.455.g172b71a6c5 In-Reply-To: <20190626000329.32475-1-avarab@gmail.com> References: <20190626000329.32475-1-avarab@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since e944d9d932 ("grep: rewrite an if/else condition to avoid duplicate expression", 2016-06-25) the "ascii_only" variable has only been used once in compile_regexp(), let's just inline it there. This makes the code easier to read, and might make it marginally faster depending on compiler optimizations. Signed-off-by: Ævar Arnfjörð Bjarmason --- grep.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grep.c b/grep.c index 1de4ab49c0..4e8d0645a8 100644 --- a/grep.c +++ b/grep.c @@ -650,13 +650,11 @@ static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt) static void compile_regexp(struct grep_pat *p, struct grep_opt *opt) { - int ascii_only; int err; int regflags = REG_NEWLINE; p->word_regexp = opt->word_regexp; p->ignore_case = opt->ignore_case; - ascii_only = !has_non_ascii(p->pattern); /* * Even when -F (fixed) asks us to do a non-regexp search, we @@ -673,7 +671,7 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt) if (opt->fixed || has_null(p->pattern, p->patternlen) || is_fixed(p->pattern, p->patternlen)) - p->fixed = !p->ignore_case || ascii_only; + p->fixed = !p->ignore_case || !has_non_ascii(p->pattern); if (p->fixed) { p->kws = kwsalloc(p->ignore_case ? tolower_trans_tbl : NULL);