]> git.ipfire.org Git - thirdparty/git.git/commit - read-cache.c
read-cache: speed up has_dir_name (part 1)
authorJeff Hostetler <jeffhost@microsoft.com>
Wed, 19 Apr 2017 17:06:17 +0000 (17:06 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Apr 2017 03:33:01 +0000 (20:33 -0700)
commit06b6d81b7929ce6f5542ba869e7bb9d8e437e6f8
treef32cb511019cbb2065a5ad762d29dcc13402d111
parente5494631ed94017da862d55eb6393a0d01d8b91d
read-cache: speed up has_dir_name (part 1)

Teach has_dir_name() to see if the path of the new item
is greater than the last path in the index array before
attempting to search for it.

has_dir_name() is looking for file/directory collisions
in the index and has to consider each sub-directory
prefix in turn.  This can cause multiple binary searches
for each path.

During operations like checkout, merge_working_tree()
populates the new index in sorted order, so we expect
to be able to append in many cases.

This commit is part 1 of 2.  This commit handles the top
of has_dir_name() and the trivial optimization.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c