Commit c1151010 by Patrick Steinhardt

attrcache: replace existing file entry with `git__swap`

When doing an upsert of a file, we used to use `git__compare_and_swap`,
comparing the entry's file which is to be replaced with itself. This can
be more easily formulated by using `git__swap`, which unconditionally
replaces the value.
parent b8ab782a
...@@ -103,8 +103,11 @@ static int attr_cache_upsert(git_attr_cache *cache, git_attr_file *file) ...@@ -103,8 +103,11 @@ static int attr_cache_upsert(git_attr_cache *cache, git_attr_file *file)
GIT_REFCOUNT_OWN(file, entry); GIT_REFCOUNT_OWN(file, entry);
GIT_REFCOUNT_INC(file); GIT_REFCOUNT_INC(file);
old = git__compare_and_swap( /*
&entry->file[file->source], entry->file[file->source], file); * Replace the existing value if another thread has
* created it in the meantime.
*/
old = git__swap(entry->file[file->source], file);
if (old) { if (old) {
GIT_REFCOUNT_OWN(old, NULL); GIT_REFCOUNT_OWN(old, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment