aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2006-03-25 06:08:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:23:01 -0500
commitd74beb9f33a5f16d2965f11b275e401f225c949d (patch)
tree48f851753ebe9c9c8dd701dcdd0c5e1d7c629579 /kernel/sys.c
parent34f361ade2fb4a869f6a7714d01c04ce4cfa75d9 (diff)
[PATCH] Use unsigned int types for a faster bsearch
This patch avoids arithmetic on 'signed' types that are slower than 'unsigned'. This saves space and cpu cycles. size of kernel/sys.o before the patch (gcc-3.4.5) text data bss dec hex filename 10924 252 4 11180 2bac kernel/sys.o size of kernel/sys.o after the patch text data bss dec hex filename 10903 252 4 11159 2b97 kernel/sys.o I noticed that gcc-4.1.0 (from Fedora Core 5) even uses idiv instruction for (a+b)/2 if a and b are signed. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index 119fb0d9e24e..38bc73ede2ba 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1363,7 +1363,7 @@ static void groups_sort(struct group_info *group_info)
1363/* a simple bsearch */ 1363/* a simple bsearch */
1364int groups_search(struct group_info *group_info, gid_t grp) 1364int groups_search(struct group_info *group_info, gid_t grp)
1365{ 1365{
1366 int left, right; 1366 unsigned int left, right;
1367 1367
1368 if (!group_info) 1368 if (!group_info)
1369 return 0; 1369 return 0;
@@ -1371,7 +1371,7 @@ int groups_search(struct group_info *group_info, gid_t grp)
1371 left = 0; 1371 left = 0;
1372 right = group_info->ngroups; 1372 right = group_info->ngroups;
1373 while (left < right) { 1373 while (left < right) {
1374 int mid = (left+right)/2; 1374 unsigned int mid = (left+right)/2;
1375 int cmp = grp - GROUP_AT(group_info, mid); 1375 int cmp = grp - GROUP_AT(group_info, mid);
1376 if (cmp > 0) 1376 if (cmp > 0)
1377 left = mid + 1; 1377 left = mid + 1;