commit cc46b93
delthas
·
2026-03-11 13:01:48 +0000 UTC
parent 3fa5cbd
Clean up dead code and minor lint issues Remove unused linkEvent struct, use strings.ReplaceAll instead of strings.Replace with -1 count, and fix context leak in tryConnect by deferring the cancel function. See https://codeberg.org/lindenii/sensei/commit/2b97db323731064af7d133f161e8aac7b8e89c25 Co-authored-by: Runxi Yu <me@runxiyu.org>
1 files changed,
+4,
-7
M
app.go
M
app.go
+4,
-7
1@@ -98,10 +98,6 @@ type event struct {
2 content interface{}
3 }
4
5-type linkEvent struct {
6- link string
7-}
8-
9 type boundKey struct {
10 netID string
11 target string
12@@ -538,7 +534,8 @@ func (app *App) tryConnect() (conn net.Conn, err error) {
13 }
14 }
15
16- ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
17+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
18+ defer cancel()
19
20 dialer := &net.Dialer{
21 Timeout: 10 * time.Second,
22@@ -2502,13 +2499,13 @@ func (app *App) mergeLine(former *ui.Line, addition ui.Line) {
23 mode := string(modeStr[i+1])
24 if set {
25 if strings.Contains(f.modeUnset, mode) {
26- f.modeUnset = strings.Replace(f.modeUnset, mode, "", -1)
27+ f.modeUnset = strings.ReplaceAll(f.modeUnset, mode, "")
28 } else if !strings.Contains(f.modeSet, mode) {
29 f.modeSet += mode
30 }
31 } else {
32 if strings.Contains(f.modeSet, mode) {
33- f.modeSet = strings.Replace(f.modeSet, mode, "", -1)
34+ f.modeSet = strings.ReplaceAll(f.modeSet, mode, "")
35 } else if !strings.Contains(f.modeUnset, mode) {
36 f.modeUnset += mode
37 }