@@ -665,17 +665,24 @@ static void mark_ce_used_same_name(struct cache_entry *ce,
665
665
}
666
666
}
667
667
668
- static struct cache_entry * next_cache_entry (struct unpack_trees_options * o )
668
+ static struct cache_entry * next_cache_entry (struct unpack_trees_options * o , int * hint )
669
669
{
670
670
const struct index_state * index = o -> src_index ;
671
671
int pos = o -> cache_bottom ;
672
672
673
+ if (* hint > pos )
674
+ pos = * hint ;
675
+
673
676
while (pos < index -> cache_nr ) {
674
677
struct cache_entry * ce = index -> cache [pos ];
675
- if (!(ce -> ce_flags & CE_UNPACKED ))
678
+ if (!(ce -> ce_flags & CE_UNPACKED )) {
679
+ * hint = pos + 1 ;
676
680
return ce ;
681
+ }
677
682
pos ++ ;
678
683
}
684
+
685
+ * hint = pos ;
679
686
return NULL ;
680
687
}
681
688
@@ -1385,12 +1392,13 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
1385
1392
1386
1393
/* Are we supposed to look at the index too? */
1387
1394
if (o -> merge ) {
1395
+ int hint = -1 ;
1388
1396
while (1 ) {
1389
1397
int cmp ;
1390
1398
struct cache_entry * ce ;
1391
1399
1392
1400
if (o -> diff_index_cached )
1393
- ce = next_cache_entry (o );
1401
+ ce = next_cache_entry (o , & hint );
1394
1402
else
1395
1403
ce = find_cache_entry (info , p );
1396
1404
@@ -1719,7 +1727,7 @@ static int verify_absent(const struct cache_entry *,
1719
1727
int unpack_trees (unsigned len , struct tree_desc * t , struct unpack_trees_options * o )
1720
1728
{
1721
1729
struct repository * repo = the_repository ;
1722
- int i , ret ;
1730
+ int i , hint , ret ;
1723
1731
static struct cache_entry * dfc ;
1724
1732
struct pattern_list pl ;
1725
1733
int free_pattern_list = 0 ;
@@ -1868,13 +1876,15 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1868
1876
info .pathspec = o -> pathspec ;
1869
1877
1870
1878
if (o -> prefix ) {
1879
+ hint = -1 ;
1880
+
1871
1881
/*
1872
1882
* Unpack existing index entries that sort before the
1873
1883
* prefix the tree is spliced into. Note that o->merge
1874
1884
* is always true in this case.
1875
1885
*/
1876
1886
while (1 ) {
1877
- struct cache_entry * ce = next_cache_entry (o );
1887
+ struct cache_entry * ce = next_cache_entry (o , & hint );
1878
1888
if (!ce )
1879
1889
break ;
1880
1890
if (ce_in_traverse_path (ce , & info ))
@@ -1895,8 +1905,9 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1895
1905
1896
1906
/* Any left-over entries in the index? */
1897
1907
if (o -> merge ) {
1908
+ hint = -1 ;
1898
1909
while (1 ) {
1899
- struct cache_entry * ce = next_cache_entry (o );
1910
+ struct cache_entry * ce = next_cache_entry (o , & hint );
1900
1911
if (!ce )
1901
1912
break ;
1902
1913
if (unpack_index_entry (ce , o ) < 0 )
0 commit comments