Speed up HasUserStopwatch & GetActiveStopwatch (#23051)
GetActiveStopwatch & HasUserStopwatch is a hot piece of code that is repeatedly called and on examination of the cpu profile for TestGit it represents 0.44 seconds of CPU time. This PR reduces this time to 80ms. --------- Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <leon@kske.dev>
This commit is contained in:
@ -45,12 +45,12 @@ func TestStopwatchExists(t *testing.T) {
|
||||
func TestHasUserStopwatch(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
exists, sw, err := issues_model.HasUserStopwatch(db.DefaultContext, 1)
|
||||
exists, sw, _, err := issues_model.HasUserStopwatch(db.DefaultContext, 1)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, exists)
|
||||
assert.Equal(t, int64(1), sw.ID)
|
||||
|
||||
exists, _, err = issues_model.HasUserStopwatch(db.DefaultContext, 3)
|
||||
exists, _, _, err = issues_model.HasUserStopwatch(db.DefaultContext, 3)
|
||||
assert.NoError(t, err)
|
||||
assert.False(t, exists)
|
||||
}
|
||||
|
Reference in New Issue
Block a user