Skip to content

Attrcache cleanups - #4131

Merged
carlosmn merged 3 commits into
libgit2:masterfrom
pks-t:pks/attrcache-cleanups
Feb 22, 2017
Merged

Attrcache cleanups#4131
carlosmn merged 3 commits into
libgit2:masterfrom
pks-t:pks/attrcache-cleanups

Conversation

@pks-t

@pks-t pks-t commented Feb 21, 2017

Copy link
Copy Markdown
Member

After several hours of staring at multi-threaded attrcache, this is the depressing outcome: a few fixes to small stylistic nits which have already been bothering me the last few times I took a look at the code :/ Well, better than nothing...

Improve encapsulation by not referencing the attrcache mutex directly
but instead using the `attr_cache_lock` and `attr_cache_unlock`
functions.
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.
Remove useless indirection from `git_attr_cache__init` to
`git_attr_cache__do_init`. The difference is that the
`git_attr_cache__init` macro first checks if the cache is already
initialized and, if so, not call `git_attr_cache__do_init`. But
actually, `git_attr_cache__do_init` already does the same thing and
returns immediately if the cache is already initialized.

Remove the indirection.
@carlosmn
carlosmn merged commit c03f00e into libgit2:master Feb 22, 2017
@pks-t
pks-t deleted the pks/attrcache-cleanups branch April 7, 2017 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants