From nobody Sat Feb 05 08:45:15 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 802DC19B0592; Sat, 5 Feb 2022 08:45:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JrQvv39bpz3LMH; Sat, 5 Feb 2022 08:45:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644050715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ndzuKgaPJsEULOaYCeS0gqEGxVHQjWySHV3Ku1wXtAg=; b=nUspTUZS+f03lc1KifeKYDZzb5XNU+/cKYwQCk1ts5Skx/6bCsFVOSi9HKY3FpER4LLjt/ aJAgl10UAM5ne3pJDinjEdASJNqk4j2dRh0Y6wuqyLn7FYIkD0wjRtaecARnCdEKLeaFjI q0avgP0eoEVYZHCB/Gp/0hpNCw0W4ALC3K3mD2IZUTty8HYCQDHikmuXJPBBmfxUg4ZvCl 3FlpoRgah66nEEzDg+UDwSd7uDOUNAXGjPTeu6Ldt4niEzzxpGhV7V/mKqA042/t4mpYXu BlCm0QFY7Tt3Z4qlHW/DojxxSqrYpnEX3mRYKspQXt7+8Qa7hF5U8AOnpjBuVA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 495311C2D3; Sat, 5 Feb 2022 08:45:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2158jFiD024026; Sat, 5 Feb 2022 08:45:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2158jFub024025; Sat, 5 Feb 2022 08:45:15 GMT (envelope-from git) Date: Sat, 5 Feb 2022 08:45:15 GMT Message-Id: <202202050845.2158jFub024025@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wolfram Schneider Subject: git: a6c20ddd4a9e - main - switch from short to int for lookup table List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wosch X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a6c20ddd4a9e60aa14c0756fdb9bd72e2921506c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644050715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ndzuKgaPJsEULOaYCeS0gqEGxVHQjWySHV3Ku1wXtAg=; b=LKDKSJ/gQYN2U0KO/4fBpkcRyBMRu6JWfURwD8oLnVHIsCzb/GAD6E4kT6gJbKQ+esx+jf c4VzG5fkD0yGmrzr4W9k15qL5xIN8DMu7ctGrJ/Zk4YSdAXNAcuHrklJqoTXaixoiq7ALS c2+UyTN3OC+2S4FwzgSgGRRI125P1huPmiZaGl2wuWWp1xWTSpTNqBpacuyGj4oJZuVwGY P6vj86MEraeoqsm0Cvxm9c1vzCSxmNbHR6gfGQ3tdao55dkPPQNEuBaBQKJy9+cfI67lYk ulKRSjRh0yJNj3ijiBJ/sF7FahVSdB/xAuzEcGtqFCpoItUNZptJQBURMyqHwA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644050715; a=rsa-sha256; cv=none; b=i+oe6wpGHl5B93SJvplY12Sgb4n4KgfJ37Xo8zuiGC1mhEKMqm7en9HFWxzln2gRpFpHGW klMgy5Lvo9PNvLEKHfjl5cXcry2tCoTyPi6n2lEkp9gky5h7T4lJ1e4Vb/9+p7koCbSLzB g+TE0RpGZ7auvAQ170SiRZjjtG1IMJGEmVxD5fahpFghJBo5jIru1yLf6BcY42rg/BdEv/ 2dPxsgN+sIrCofHqCmdVtlf86fYLh/1bPI9QAetXNu1IlxGFQnjZlWDuu5XtVqhPex3qf9 s6oMN8uPWGd9F+sV2CP/V2aOTUS1TEvl/4roSbwjhnGbM/9ly/5pnZzQ38ZZCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=a6c20ddd4a9e60aa14c0756fdb9bd72e2921506c commit a6c20ddd4a9e60aa14c0756fdb9bd72e2921506c Author: Wolfram Schneider AuthorDate: 2022-02-05 08:44:35 +0000 Commit: Wolfram Schneider CommitDate: 2022-02-05 08:44:35 +0000 switch from short to int for lookup table This simplifies the code, less casting is needed. --- usr.bin/locate/code/locate.code.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c index f352cb2e6f6e..abac253a9237 100644 --- a/usr.bin/locate/code/locate.code.c +++ b/usr.bin/locate/code/locate.code.c @@ -107,9 +107,8 @@ u_char buf2[LOCATE_PATH_MAX]; u_char bigrams[BGBUFSIZE + 1] = { 0 }; /* use a lookup array instead a function, 3x faster than linear search */ +int big [UCHAR_MAX + 1][UCHAR_MAX + 1]; #define BGINDEX(x) (big[(u_char)*x][(u_char)*(x + 1)]) -typedef short bg_t; -bg_t big[UCHAR_MAX + 1][UCHAR_MAX + 1]; void usage(void); @@ -148,10 +147,10 @@ main(int argc, char *argv[]) /* init lookup table */ for (i = 0; i < UCHAR_MAX + 1; i++) for (j = 0; j < UCHAR_MAX + 1; j++) - big[i][j] = (bg_t)-1; + big[i][j] = -1; for (cp = bigrams, i = 0; *cp != '\0'; i += 2, cp += 2) - big[(u_char)*cp][(u_char)*(cp + 1)] = (bg_t)i; + big[(u_char)*cp][(u_char)*(cp + 1)] = i; oldpath = buf1; path = buf2; @@ -189,7 +188,7 @@ main(int argc, char *argv[]) while (*cp != '\0') { /* print *two* characters */ - if ((code = BGINDEX(cp)) != (bg_t)-1) { + if ((code = BGINDEX(cp)) != -1) { /* * print *one* as bigram * Found, so mark byte with