Skip to content

Commit

Permalink
refactor: rename variable to reflect reality
Browse files Browse the repository at this point in the history
This commit renames varibles and method names to better reflect reality.
  • Loading branch information
maeb committed May 15, 2024
1 parent be20430 commit 8977142
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions internal/badgeridx/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (db *DB) closest(ctx context.Context, request index.Request, results chan<-
closest := ts.Unix()
isClosest := timestamp.CompareClosest(closest)
matchType := request.MatchType()
_, schemeAndUserInfo, _ := keyvalue.SplitSSURT(request.Ssurt())
_, portSchemeUserInfo, _ := keyvalue.SplitSSURT(request.Ssurt())

go func() {
defer close(results)
Expand Down Expand Up @@ -196,7 +196,7 @@ func (db *DB) closest(ctx context.Context, request index.Request, results chan<-
}
key := keyvalue.CdxKey(iter.Item().Key())
if matchType == index.MatchTypeVerbatim {
if key.SchemeAndUserInfo() != schemeAndUserInfo {
if key.PortSchemeUserInfo() != portSchemeUserInfo {
iter.Next()
continue
}
Expand Down Expand Up @@ -242,7 +242,7 @@ func (db *DB) Search(ctx context.Context, search index.Request, results chan<- i

// search the index database.
func (db *DB) search(ctx context.Context, req index.Request, results chan<- index.CdxResponse) error {
_, schemeAndUserInfo, _ := keyvalue.SplitSSURT(req.Ssurt())
_, portSchemeUserInfo, _ := keyvalue.SplitSSURT(req.Ssurt())
reverse := req.Sort() == index.SortDesc
prefix := keyvalue.SearchKey(req)

Expand Down Expand Up @@ -274,7 +274,7 @@ func (db *DB) search(ctx context.Context, req index.Request, results chan<- inde
return nil
}
if matchType == index.MatchTypeVerbatim {
if key.SchemeAndUserInfo() != schemeAndUserInfo {
if key.PortSchemeUserInfo() != portSchemeUserInfo {
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/keyvalue/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (ck CdxKey) Unix() int64 {
return ck.Time().Unix()
}

func (ck CdxKey) SchemeAndUserInfo() string {
func (ck CdxKey) PortSchemeUserInfo() string {
parts := bytes.Split(ck, spaceCharacter)
if len(parts) < 3 {
return ""
Expand Down
4 changes: 2 additions & 2 deletions internal/keyvalue/ssurt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strings"
)

func SplitSSURT(ssurt string) (surtHost string, schemeAndUserinfo string, path string) {
func SplitSSURT(ssurt string) (surtHost string, portSchemeUserInfo string, path string) {
i := strings.Index(ssurt, "//")
if i == -1 {
return ssurt, "", ""
Expand All @@ -38,7 +38,7 @@ func SplitSSURT(ssurt string) (surtHost string, schemeAndUserinfo string, path s
if j == -1 {
return surtHost, ssurt[i+2:], ""
}
schemeAndUserinfo = ssurt[i+2 : i+2+j]
portSchemeUserInfo = ssurt[i+2 : i+2+j]

path = ssurt[i+2+j:]

Expand Down
4 changes: 2 additions & 2 deletions internal/tikvidx/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (db *DB) Search(ctx context.Context, req index.Request, res chan<- index.Cd
return nil
}
matchType := req.MatchType()
_, schemeAndUserInfo, _ := keyvalue.SplitSSURT(req.Ssurt())
_, portSchemeUserInfo, _ := keyvalue.SplitSSURT(req.Ssurt())

go func() {
defer close(res)
Expand All @@ -137,7 +137,7 @@ func (db *DB) Search(ctx context.Context, req index.Request, res chan<- index.Cd
return nil
}
if matchType == index.MatchTypeVerbatim {
if cdxKey.SchemeAndUserInfo() != schemeAndUserInfo {
if cdxKey.PortSchemeUserInfo() != portSchemeUserInfo {
return nil
}
}
Expand Down

0 comments on commit 8977142

Please sign in to comment.