* view.c (view_ccache_find): Replaced the linear search with a
binary search. This speeds up the viewer by a factor of 25 for large files (> 100 MB).
Этот коммит содержится в:
родитель
ca15b965d6
Коммит
b8969ae3df
@ -1,3 +1,9 @@
|
|||||||
|
2005-07-07 Roland Illig <roland.illig@gmx.de>
|
||||||
|
|
||||||
|
* view.c (view_ccache_find): Replaced the linear search with a
|
||||||
|
binary search. This speeds up the viewer by a factor of 25 for
|
||||||
|
large files (> 100 MB).
|
||||||
|
|
||||||
2005-07-07 Roland Illig <roland.illig@gmx.de>
|
2005-07-07 Roland Illig <roland.illig@gmx.de>
|
||||||
|
|
||||||
* dialog.h: Replaced object-like macros with implicit references
|
* dialog.h: Replaced object-like macros with implicit references
|
||||||
|
44
src/view.c
44
src/view.c
@ -810,34 +810,7 @@ is_nroff_sequence (WView *view, offset_type offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline guint
|
static inline guint
|
||||||
view_ccache_find_linear_down (WView *view, const struct coord_cache_entry *cache,
|
view_ccache_find (WView *view, const struct coord_cache_entry *cache,
|
||||||
const struct coord_cache_entry *coord, enum ccache_type sort_by)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
for (i = 0; i + 1 < view->coord_cache->len; i++) {
|
|
||||||
if (coord_cache_entry_less (coord, &(cache[i + 1]), sort_by, view->text_nroff_mode))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline guint
|
|
||||||
view_ccache_find_linear_up (WView *view, const struct coord_cache_entry *cache,
|
|
||||||
const struct coord_cache_entry *coord, enum ccache_type sort_by)
|
|
||||||
{
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
i = view->coord_cache->len;
|
|
||||||
assert (i != 0);
|
|
||||||
do {
|
|
||||||
i--;
|
|
||||||
} while (coord_cache_entry_less (coord, &cache[i], sort_by, view->text_nroff_mode));
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline guint
|
|
||||||
view_ccache_find_binary (WView *view, const struct coord_cache_entry *cache,
|
|
||||||
const struct coord_cache_entry *coord, enum ccache_type sort_by)
|
const struct coord_cache_entry *coord, enum ccache_type sort_by)
|
||||||
{
|
{
|
||||||
guint base, i, limit;
|
guint base, i, limit;
|
||||||
@ -859,21 +832,6 @@ view_ccache_find_binary (WView *view, const struct coord_cache_entry *cache,
|
|||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline guint
|
|
||||||
view_ccache_find (WView *view, const struct coord_cache_entry *cache,
|
|
||||||
const struct coord_cache_entry *coord, enum ccache_type sort_by)
|
|
||||||
{
|
|
||||||
volatile guint linear_down, linear_up, binary;
|
|
||||||
|
|
||||||
linear_down = view_ccache_find_linear_down (view, cache, coord, sort_by);
|
|
||||||
linear_up = view_ccache_find_linear_up (view, cache, coord, sort_by);
|
|
||||||
binary = view_ccache_find_binary (view, cache, coord, sort_by);
|
|
||||||
|
|
||||||
assert (linear_down == linear_up);
|
|
||||||
assert (linear_down == binary);
|
|
||||||
return binary;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look up the missing components of ''coord'', which are given by
|
/* Look up the missing components of ''coord'', which are given by
|
||||||
* ''lookup_what''. The function returns the smallest value that
|
* ''lookup_what''. The function returns the smallest value that
|
||||||
* matches the existing components of ''coord''.
|
* matches the existing components of ''coord''.
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user