diff options
| author | Jiang Xin <worldhello.net@gmail.com> | 2020-12-21 07:10:19 +0800 |
|---|---|---|
| committer | Jiang Xin <worldhello.net@gmail.com> | 2020-12-21 07:10:19 +0800 |
| commit | 3104153d5ea3bd0e68166e02ec847a895f9a76e6 (patch) | |
| tree | 8b65383c203c550fab3f6ffea51cd474168ac34b /oid-array.c | |
| parent | l10n: Update Catalan translation (diff) | |
| parent | Git 2.30-rc1 (diff) | |
| download | git-3104153d5ea3bd0e68166e02ec847a895f9a76e6.tar.gz git-3104153d5ea3bd0e68166e02ec847a895f9a76e6.zip | |
Merge remote-tracking branch 'github/master' into git-po-master
* github/master: (42 commits)
Git 2.30-rc1
git-gui: use gray background for inactive text widgets
Another batch before 2.30-rc1
git-gui: Fix selected text colors
Makefile: conditionally include GIT-VERSION-FILE
git-gui: fix colored label backgrounds when using themed widgets
config.mak.uname: remove old NonStop compatibility settings
diff: correct interaction between --exit-code and -I<pattern>
t/perf: fix test_export() failure with BSD `sed`
style: do not "break" in switch() after "return"
compat-util: pretend that stub setitimer() always succeeds
strmap: make callers of strmap_remove() to call it in void context
doc: mention Python 3.x supports
index-format.txt: document v2 format of file system monitor extension
docs: multi-pack-index: remove note about future 'verify' work
init: provide useful advice about init.defaultBranch
get_default_branch_name(): prepare for showing some advice
branch -m: allow renaming a yet-unborn branch
init: document `init.defaultBranch` better
t7900: use --fixed-value in git-maintenance tests
...
Diffstat (limited to 'oid-array.c')
| -rw-r--r-- | oid-array.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/oid-array.c b/oid-array.c index 8657a5cedf..8e1bcedc0c 100644 --- a/oid-array.c +++ b/oid-array.c @@ -14,8 +14,10 @@ static int void_hashcmp(const void *a, const void *b) return oidcmp(a, b); } -static void oid_array_sort(struct oid_array *array) +void oid_array_sort(struct oid_array *array) { + if (array->sorted) + return; QSORT(array->oid, array->nr, void_hashcmp); array->sorted = 1; } @@ -28,8 +30,7 @@ static const unsigned char *sha1_access(size_t index, void *table) int oid_array_lookup(struct oid_array *array, const struct object_id *oid) { - if (!array->sorted) - oid_array_sort(array); + oid_array_sort(array); return sha1_pos(oid->hash, array->oid, array->nr, sha1_access); } @@ -64,14 +65,10 @@ int oid_array_for_each_unique(struct oid_array *array, { size_t i; - if (!array->sorted) - oid_array_sort(array); + oid_array_sort(array); - for (i = 0; i < array->nr; i++) { - int ret; - if (i > 0 && oideq(array->oid + i, array->oid + i - 1)) - continue; - ret = fn(array->oid + i, data); + for (i = 0; i < array->nr; i = oid_array_next_unique(array, i)) { + int ret = fn(array->oid + i, data); if (ret) return ret; } |
