Skip to content

Commit 6f8401f

Browse files
committed
chore_: remove code branching
1 parent ab7c27a commit 6f8401f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

api/geth_backend.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,15 +3050,13 @@ func (b *GethStatusBackend) ReleaseOSMemory() error {
30503050
b.lastGCTimeLock.Lock()
30513051
defer b.lastGCTimeLock.Unlock()
30523052

3053-
var err error
30543053
// Only run GC if 10 seconds have passed since the last call
3055-
if time.Since(b.lastGCTime) >= gcInterval {
3056-
b.releaseOSMemory()
3057-
b.lastGCTime = time.Now()
3058-
} else {
3059-
err = errors.New("skipping GC because it was called too recently")
3054+
if time.Since(b.lastGCTime) < gcInterval {
3055+
return errors.New("skipping GC because it was called too recently")
30603056
}
3061-
return err
3057+
b.releaseOSMemory()
3058+
b.lastGCTime = time.Now()
3059+
return nil
30623060
}
30633061

30643062
func (b *GethStatusBackend) releaseOSMemory() {

0 commit comments

Comments
 (0)