mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-11 05:49:18 +03:00
Provided multiple versions of view_ccache_find(), which can be selected by
defining C preprocessor symbols.
This commit is contained in:
parent
bc446f0cee
commit
0072aeb2e5
63
src/view.c
63
src/view.c
@ -809,6 +809,64 @@ is_nroff_sequence (WView *view, offset_type offset)
|
|||||||
return (c0 == c2 || c0 == '_' || (c0 == '+' && c2 == 'o'));
|
return (c0 == c2 || c0 == '_' || (c0 == '+' && c2 == 'o'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MCVIEW_USE_FIND_LINEAR_DOWN
|
||||||
|
|
||||||
|
#ifdef MCVIEW_USE_FIND_LINEAR_DOWN
|
||||||
|
static inline guint
|
||||||
|
view_ccache_find_linear_down (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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MCVIEW_USE_FIND_LINEAR_UP
|
||||||
|
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;
|
||||||
|
if (i != 0) {
|
||||||
|
do {
|
||||||
|
i--;
|
||||||
|
} while (coord_cache_entry_less (coord, &cache[i], sort_by, view->text_nroff_mode));
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MCVIEW_USE_FIND_BINARY
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
abort(); /* does not work yet */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
#if defined(MCVIEW_USE_FIND_LINEAR_DOWN)
|
||||||
|
return view_ccache_find_linear_down (view, cache, coord, sort_by);
|
||||||
|
#elif defined(MCVIEW_USE_FIND_LINEAR_UP)
|
||||||
|
return view_ccache_find_linear_up (view, cache, coord, sort_by);
|
||||||
|
#elif defined(MCVIEW_USE_FIND_BINARY)
|
||||||
|
return view_ccache_find_binary (view, cache, coord, sort_by);
|
||||||
|
#else
|
||||||
|
# error No find function defined.
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* 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''.
|
||||||
@ -841,10 +899,7 @@ view_ccache_lookup (WView *view, struct coord_cache_entry *coord,
|
|||||||
retry:
|
retry:
|
||||||
/* find the two neighbor entries in the cache */
|
/* find the two neighbor entries in the cache */
|
||||||
cache = &(g_array_index (view->coord_cache, struct coord_cache_entry, 0));
|
cache = &(g_array_index (view->coord_cache, struct coord_cache_entry, 0));
|
||||||
for (i = 0; i + 1 < view->coord_cache->len; i++) {
|
i = view_ccache_find (view, cache, coord, sorter);
|
||||||
if (coord_cache_entry_less (coord, &(cache[i + 1]), sorter, view->text_nroff_mode))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* now i points to the lower neighbor in the cache */
|
/* now i points to the lower neighbor in the cache */
|
||||||
|
|
||||||
current = cache[i];
|
current = cache[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user