BurntSushi / BurntSushi/locker
Comment
- Dominant language
- Go
- Stars
- 36
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Looks like the calls to `lker.getLock` are unnecessy in `Lock` and `RLock` impelmentation
e.g. This
```golang
func (lker *Locker) Lock(key string) {
lk, ok := lker.getLock(key)
if !ok {
lk = lker.newLock(key)
}
lk.Lock()
}
func (lker *Locker) RLock(key string) {
lk, ok := lker.getLock(key)
if !ok {
lk = lker.newLock(key)
}
lk.RLock()
}
```
can be simplified to
```golang
func (lker *Locker) Lock(key string) {
lker.newLock(key).Lock();
}
func (lker *Locker) RLock(key string) {
lker.newLock(key).RLock()
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Locker.Lock and Locker.RLock entry points shown in the issue, then inspect newLock to understand how lock creation and lookup work. Confirm that simplifying both methods preserves named-lock behavior, and run the repository's existing tests if available; done means both methods use the proposed direct locking flow without changing semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100