diff options
author | Kazu Hirata <kazu@cs.umass.edu> | 2004-11-26 07:07:00 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2004-11-26 07:07:00 +0000 |
commit | 3aeee1b434bd034fafff6aeb5309c565e74e3f41 (patch) | |
tree | 70570fb44f35a4e72fc9fc581481500db1e54681 /gcc/bitmap.c | |
parent | 6a66a8a7a2bf2db8fa48d5e3abd758c66e10b6cd (diff) | |
download | gcc-3aeee1b434bd034fafff6aeb5309c565e74e3f41.zip gcc-3aeee1b434bd034fafff6aeb5309c565e74e3f41.tar.gz gcc-3aeee1b434bd034fafff6aeb5309c565e74e3f41.tar.bz2 |
bitmap.c (bitmap_find_bit): Speed up by traversing from head->first if that seems profitable.
* bitmap.c (bitmap_find_bit): Speed up by traversing from
head->first if that seems profitable.
From-SVN: r91335
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r-- | gcc/bitmap.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/bitmap.c b/gcc/bitmap.c index f633505..140dd00 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -401,14 +401,26 @@ bitmap_find_bit (bitmap head, unsigned int bit) || head->indx == indx) return head->current; - if (head->indx > indx) + if (head->indx < indx) + /* INDX is beyond head->indx. Search from head->current + forward. */ + for (element = head->current; + element->next != 0 && element->indx < indx; + element = element->next) + ; + + else if (head->indx / 2 < indx) + /* INDX is less than head->indx and closer to head->indx than to + 0. Search from head->current backward. */ for (element = head->current; element->prev != 0 && element->indx > indx; element = element->prev) ; else - for (element = head->current; + /* INDX is less than head->indx and closer to 0 than to + head->indx. Search from head->first forward. */ + for (element = head->first; element->next != 0 && element->indx < indx; element = element->next) ; |