Skip to content

Commit

Permalink
remove unnecessary type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Feb 24, 2024
1 parent e1d1e52 commit 8b1b445
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/byte_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestByteGenerator(t *testing.T) {
{
err := g.Generate(s)
is.NotErr(err)
password := string(s.Output())
password := s.Output()
is.Equal(2, len(password))
is.Equal(password, strings.ToLower(password))
}
Expand All @@ -35,7 +35,7 @@ func TestByteGenerator2(t *testing.T) {
{
err := g.Generate(s)
is.NotErr(err)
password := string(s.Output())
password := s.Output()
is.Equal(2, len(password))
is.Equal(password, strings.ToUpper(password))
}
Expand Down
2 changes: 1 addition & 1 deletion lib/date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestDateGenerator(t *testing.T) {
{
err := g.Generate(s)
is.NotErr(err)
is.Equal(10, len(string(s.Output())))
is.Equal(10, len(s.Output()))
}
{
entropy, err := g.Entropy(s)
Expand Down
2 changes: 1 addition & 1 deletion lib/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (g *encoderFunctionCallGenerator) Generate(s *State) error {
}
err := baseFunctionCallGenerator(
s,
NewState(s.SharedState, []rune(g.argPattern)),
NewState(s.SharedState, g.argPattern),
funcObj,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions lib/jp_romaji.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func InitRomaji() {
tables := []string{HiraganaTable, KatakanaTable}
for _, table := range tables {
rows := strings.Split(table, "\n")
colNames := strings.Split(string(rows[0]), "\t")[1:]
colNames := strings.Split(rows[0], "\t")[1:]
for _, row := range rows[1:] {
cols := strings.Split(string(row), "\t")
cols := strings.Split(row, "\t")
rowName := cols[0]
for i, kana := range cols[1:] {
value := rowName + colNames[i]
Expand Down
6 changes: 3 additions & 3 deletions lib/justify.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func center(in []rune, width int, fillChar rune) []rune {
return in
}
out := make([]rune, width)
fcc := int((width - len(in)) / 2)
fcc := (width - len(in)) / 2
for i := range fcc {
out[i] = fillChar
}
Expand Down Expand Up @@ -88,7 +88,7 @@ func parseJustifyArgs(s *State, argsStr []rune, funcName string) (*JustifyArgs,
s.errorOffset += int64(len(argsStr) + 1)
return nil, s.errorArg("%s: at least 2 arguments are required", funcName)
}
pattern := []rune(args[0])
pattern := args[0]
width, err := strconv.Atoi(strings.TrimSpace(string(args[1])))
if err != nil {
s.errorOffset += int64(len(args[0]) + len(args[1]) + 1)
Expand All @@ -102,7 +102,7 @@ func parseJustifyArgs(s *State, argsStr []rune, funcName string) (*JustifyArgs,
}
fillChar := ' '
if len(args) > 2 {
fillCharA := []rune(args[2])
fillCharA := args[2]
if len(fillCharA) != 1 {
s.errorOffset += int64(len(args[0]) + len(args[1]) + len(args[2]) + 2)
s.errorMarkLen = len(args[2])
Expand Down
2 changes: 1 addition & 1 deletion lib/static_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestStaticStringGenerator(t *testing.T) {
{
err := g.Generate(s)
is.NotErr(err)
is.Equal(pattern, string(s.Output()))
is.Equal(pattern, s.Output())
}
{
entropy, err := g.Entropy(s)
Expand Down
4 changes: 2 additions & 2 deletions lib/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Benchmark_removeDuplicateRunes(b *testing.B) {
for i := range count {
list := make([]rune, listLength)
for j := 0; j < listLength; j++ {
list[j] = rune(math_rand.Int32N(256))
list[j] = math_rand.Int32N(256)
}
lists[i] = list
}
Expand All @@ -64,7 +64,7 @@ func Benchmark_excludeCharsASCII(b *testing.B) {
for i := range count {
list := make([]rune, listLength)
for j := 0; j < listLength; j++ {
list[j] = rune(math_rand.Int32N(256))
list[j] = math_rand.Int32N(256)
}
lists[i] = list
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func printError(err error, pattern string) {
fmt.Println(err)
return
}
fmt.Println(string(pattern))
fmt.Println(pattern)
fmt.Println(myErr.SpacedError())
}

Expand Down

0 comments on commit 8b1b445

Please sign in to comment.