@@ -458,6 +458,7 @@ typedef struct {
458
458
git_pool pool ;
459
459
git_vector loose ;
460
460
461
+ git_sortedcache * cache ;
461
462
size_t loose_pos ;
462
463
size_t packed_pos ;
463
464
} refdb_fs_iter ;
@@ -468,6 +469,7 @@ static void refdb_fs_backend__iterator_free(git_reference_iterator *_iter)
468
469
469
470
git_vector_free (& iter -> loose );
470
471
git_pool_clear (& iter -> pool );
472
+ git_sortedcache_free (iter -> cache );
471
473
git__free (iter );
472
474
}
473
475
@@ -539,10 +541,14 @@ static int refdb_fs_backend__iterator_next(
539
541
giterr_clear ();
540
542
}
541
543
542
- git_sortedcache_rlock (backend -> refcache );
544
+ if (!iter -> cache ) {
545
+ if ((error = git_sortedcache_copy (& iter -> cache , backend -> refcache , 1 , NULL , NULL )) < 0 )
546
+ return error ;
547
+ }
543
548
544
- while (iter -> packed_pos < git_sortedcache_entrycount (backend -> refcache )) {
545
- ref = git_sortedcache_entry (backend -> refcache , iter -> packed_pos ++ );
549
+ error = GIT_ITEROVER ;
550
+ while (iter -> packed_pos < git_sortedcache_entrycount (iter -> cache )) {
551
+ ref = git_sortedcache_entry (iter -> cache , iter -> packed_pos ++ );
546
552
if (!ref ) /* stop now if another thread deleted refs and we past end */
547
553
break ;
548
554
@@ -556,7 +562,6 @@ static int refdb_fs_backend__iterator_next(
556
562
break ;
557
563
}
558
564
559
- git_sortedcache_runlock (backend -> refcache );
560
565
return error ;
561
566
}
562
567
@@ -579,10 +584,14 @@ static int refdb_fs_backend__iterator_next_name(
579
584
giterr_clear ();
580
585
}
581
586
582
- git_sortedcache_rlock (backend -> refcache );
587
+ if (!iter -> cache ) {
588
+ if ((error = git_sortedcache_copy (& iter -> cache , backend -> refcache , 1 , NULL , NULL )) < 0 )
589
+ return error ;
590
+ }
583
591
584
- while (iter -> packed_pos < git_sortedcache_entrycount (backend -> refcache )) {
585
- ref = git_sortedcache_entry (backend -> refcache , iter -> packed_pos ++ );
592
+ error = GIT_ITEROVER ;
593
+ while (iter -> packed_pos < git_sortedcache_entrycount (iter -> cache )) {
594
+ ref = git_sortedcache_entry (iter -> cache , iter -> packed_pos ++ );
586
595
if (!ref ) /* stop now if another thread deleted refs and we past end */
587
596
break ;
588
597
@@ -596,7 +605,6 @@ static int refdb_fs_backend__iterator_next_name(
596
605
break ;
597
606
}
598
607
599
- git_sortedcache_runlock (backend -> refcache );
600
608
return error ;
601
609
}
602
610
0 commit comments