Commit fffe429a20b68677cae940ba8a9a0ff60056d6c0

Russell Belfer 2013-01-10T11:11:42

Shortcut spool and sort for empty iterator

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/iterator.c b/src/iterator.c
index 0b6a4fc..56b2629 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -1032,6 +1032,11 @@ int git_iterator_spoolandsort_push(git_iterator *iter, bool ignore_case)
 	if (((iter->flags & GIT_ITERATOR_IGNORE_CASE) != 0) == (ignore_case != 0))
 		return 0;
 
+	if (iter->type == GIT_ITERATOR_TYPE_EMPTY) {
+		iter->flags = (iter->flags ^ GIT_ITERATOR_IGNORE_CASE);
+		return 0;
+	}
+
 	scb = git__calloc(1, sizeof(spoolandsort_callbacks));
 	GITERR_CHECK_ALLOC(scb);