From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 617CB3858C78 for ; Thu, 3 Feb 2022 22:28:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 617CB3858C78 Received: by mail-oi1-x230.google.com with SMTP id r27so6368988oiw.4 for ; Thu, 03 Feb 2022 14:28:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BecYNI/mWyJycG/cEUh+qmIc1t/G9mwYN1Yb5TPmWaw=; b=SVvUvuseJeJ4QA3W0i5b7Ag+uU/zLM0p7dRN7xtaW86Orkxd1SPD7yzOAAK3SsOVcN bHie9nrjwR9nPe0FMJ0djNUfk1U4LcZTLOGK+XuxCKPERoM/g9Dpw/MpBbDUlkNFZour 3elfkuTZ0UswYpmr/qiVJY+huJ/wZC6n6NwQqkzBnsw95sLvsrcEWQMnnisq8ruXgweq ocqRV7PCJnsn3agnSnAVKSrTHr825Pt5v9QE2QwyNksalz5E3VnVv6PXjRNRYd5+OiTZ w5+celDdrGssMC5UZToqMzu1EVbrgLzdcbv1lcLatjMWw58EEt72v7X5SVhvM54n6ncI AP3w== X-Gm-Message-State: AOAM532pNoxe7HwKKN/SQnx4T66wGe3mDGrLxxAf7VfediAzqtp24Tog ZEIieDtGzoKG+nJcdEstEudOcENxsFgO2gR2NAo= X-Google-Smtp-Source: ABdhPJzfU+fXBjST+g/XtUOd2yoHab9ZzcT703EwN1X7kS4cZd9gDEPahFWO92rOB2Pfxzy8dKhlbDtnUfp6Oq4GtuE= X-Received: by 2002:a05:6808:159e:: with SMTP id t30mr35603oiw.132.1643927334659; Thu, 03 Feb 2022 14:28:54 -0800 (PST) MIME-Version: 1.0 References: <20220203214215.3275256-1-goldstein.w.n@gmail.com> In-Reply-To: <20220203214215.3275256-1-goldstein.w.n@gmail.com> From: "H.J. Lu" Date: Thu, 3 Feb 2022 14:28:18 -0800 Message-ID: Subject: Re: [PATCH v4 1/5] string/test-str*cmp: remove stupid_[strcmp, strncmp, wcscmp, wcsncmp]. To: Noah Goldstein Cc: GNU C Library , "Carlos O'Donell" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3027.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Feb 2022 22:28:56 -0000 On Thu, Feb 3, 2022 at 1:42 PM Noah Goldstein wrote: > > These implementations just add to test duration. Since we have > simple_* implementations we already have a safe reference > implementation. > > Signed-off-by: Noah Goldstein > --- > string/test-strcmp.c | 35 ----------------------------------- > string/test-strncmp.c | 34 ---------------------------------- > 2 files changed, 69 deletions(-) > > diff --git a/string/test-strcmp.c b/string/test-strcmp.c > index 3c75076fb8..97d7bf5043 100644 > --- a/string/test-strcmp.c > +++ b/string/test-strcmp.c > @@ -34,7 +34,6 @@ > # define STRLEN wcslen > # define MEMCPY wmemcpy > # define SIMPLE_STRCMP simple_wcscmp > -# define STUPID_STRCMP stupid_wcscmp > # define CHAR wchar_t > # define UCHAR wchar_t > # define CHARBYTES 4 > @@ -64,25 +63,6 @@ simple_wcscmp (const wchar_t *s1, const wchar_t *s2) > return c1 < c2 ? -1 : 1; > } > > -int > -stupid_wcscmp (const wchar_t *s1, const wchar_t *s2) > -{ > - size_t ns1 = wcslen (s1) + 1; > - size_t ns2 = wcslen (s2) + 1; > - size_t n = ns1 < ns2 ? ns1 : ns2; > - int ret = 0; > - > - wchar_t c1, c2; > - > - while (n--) { > - c1 = *s1++; > - c2 = *s2++; > - if ((ret = c1 < c2 ? -1 : c1 == c2 ? 0 : 1) != 0) > - break; > - } > - return ret; > -} > - > #else > # include > > @@ -92,7 +72,6 @@ stupid_wcscmp (const wchar_t *s1, const wchar_t *s2) > # define STRLEN strlen > # define MEMCPY memcpy > # define SIMPLE_STRCMP simple_strcmp > -# define STUPID_STRCMP stupid_strcmp > # define CHAR char > # define UCHAR unsigned char > # define CHARBYTES 1 > @@ -113,24 +92,10 @@ simple_strcmp (const char *s1, const char *s2) > return ret; > } > > -int > -stupid_strcmp (const char *s1, const char *s2) > -{ > - size_t ns1 = strlen (s1) + 1; > - size_t ns2 = strlen (s2) + 1; > - size_t n = ns1 < ns2 ? ns1 : ns2; > - int ret = 0; > - > - while (n--) > - if ((ret = *(unsigned char *) s1++ - *(unsigned char *) s2++) != 0) > - break; > - return ret; > -} > #endif > > typedef int (*proto_t) (const CHAR *, const CHAR *); > > -IMPL (STUPID_STRCMP, 1) > IMPL (SIMPLE_STRCMP, 1) > IMPL (STRCMP, 1) > > diff --git a/string/test-strncmp.c b/string/test-strncmp.c > index e7d5edea39..61a283a0af 100644 > --- a/string/test-strncmp.c > +++ b/string/test-strncmp.c > @@ -33,7 +33,6 @@ > # define STRDUP wcsdup > # define MEMCPY wmemcpy > # define SIMPLE_STRNCMP simple_wcsncmp > -# define STUPID_STRNCMP stupid_wcsncmp > # define CHAR wchar_t > # define UCHAR wchar_t > # define CHARBYTES 4 > @@ -57,25 +56,6 @@ simple_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n) > return 0; > } > > -int > -stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n) > -{ > - wchar_t c1, c2; > - size_t ns1 = wcsnlen (s1, n) + 1, ns2 = wcsnlen (s2, n) + 1; > - > - n = ns1 < n ? ns1 : n; > - n = ns2 < n ? ns2 : n; > - > - while (n--) > - { > - c1 = *s1++; > - c2 = *s2++; > - if (c1 != c2) > - return c1 > c2 ? 1 : -1; > - } > - return 0; > -} > - > #else > # define L(str) str > # define STRNCMP strncmp > @@ -83,7 +63,6 @@ stupid_wcsncmp (const CHAR *s1, const CHAR *s2, size_t n) > # define STRDUP strdup > # define MEMCPY memcpy > # define SIMPLE_STRNCMP simple_strncmp > -# define STUPID_STRNCMP stupid_strncmp > # define CHAR char > # define UCHAR unsigned char > # define CHARBYTES 1 > @@ -101,23 +80,10 @@ simple_strncmp (const char *s1, const char *s2, size_t n) > return ret; > } > > -int > -stupid_strncmp (const char *s1, const char *s2, size_t n) > -{ > - size_t ns1 = strnlen (s1, n) + 1, ns2 = strnlen (s2, n) + 1; > - int ret = 0; > - > - n = ns1 < n ? ns1 : n; > - n = ns2 < n ? ns2 : n; > - while (n-- && (ret = *(unsigned char *) s1++ - * (unsigned char *) s2++) == 0); > - return ret; > -} > - > #endif > > typedef int (*proto_t) (const CHAR *, const CHAR *, size_t); > > -IMPL (STUPID_STRNCMP, 0) > IMPL (SIMPLE_STRNCMP, 0) > IMPL (STRNCMP, 1) > > -- > 2.25.1 > LGTM. Reviewed-by: H.J. Lu Thanks. -- H.J.