645
}
646
}
647
648
-static struct cache_entry *next_cache_entry(struct unpack_trees_options *o)
648
+static struct cache_entry *next_cache_entry(struct unpack_trees_options *o, int *hint)
649
{
650
const struct index_state *index = o->src_index;
651
int pos = o->cache_bottom;
652
653
+ if (*hint > pos)
654
+ pos = *hint;
655
+
656
while (pos < index->cache_nr) {
657
struct cache_entry *ce = index->cache[pos];
655
- if (!(ce->ce_flags & CE_UNPACKED))
658
+ if (!(ce->ce_flags & CE_UNPACKED)) {
659
+ *hint = pos + 1;
660
return ce;
661
+ }
662
pos++;
663
}
664
+
665
+ *hint = pos;
666
return NULL;
667
}
668
1372
1373
/* Are we supposed to look at the index too? */
1374
if (o->merge) {
1375
+ int hint = -1;
1376
while (1) {
1377
int cmp;
1378
struct cache_entry *ce;
1379
1380
if (o->diff_index_cached)
1373
- ce = next_cache_entry(o);
1381
+ ce = next_cache_entry(o, &hint);
1382
else
1383
ce = find_cache_entry(info, p);
1384
1698
int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
1699
{
1700
struct repository *repo = the_repository;
1693
- int i, ret;
1701
+ int i, hint, ret;
1702
static struct cache_entry *dfc;
1703
struct pattern_list pl;
1704
int free_pattern_list = 0;
1771
info.pathspec = o->pathspec;
1772
1773
if (o->prefix) {
1774
+ hint = -1;
1775
+
1776
/*
1777
* Unpack existing index entries that sort before the
1778
* prefix the tree is spliced into. Note that o->merge
1779
* is always true in this case.
1780
*/
1781
while (1) {
1772
- struct cache_entry *ce = next_cache_entry(o);
1782
+ struct cache_entry *ce = next_cache_entry(o, &hint);
1783
if (!ce)
1784
break;
1785
if (ce_in_traverse_path(ce, &info))
1800
1801
/* Any left-over entries in the index? */
1802
if (o->merge) {
1803
+ hint = -1;
1804
while (1) {
1794
- struct cache_entry *ce = next_cache_entry(o);
1805
+ struct cache_entry *ce = next_cache_entry(o, &hint);
1806
if (!ce)
1807
break;
1808
if (unpack_index_entry(ce, o) < 0)