Skip to content

Commit

Permalink
Refactors if to switch
Browse files Browse the repository at this point in the history
Refactors ASCII conversion for readability.
  • Loading branch information
topfunky committed May 15, 2024
1 parent 0d7cc32 commit 19f0152
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ func removeNonASCII(str string) string {
// Replace non-ASCII characters with their ASCII equivalents
var result strings.Builder
for _, char := range str {
if asciiChar, ok := nonASCIItoASCII[char]; ok {
asciiChar, isCharMappedToASCII := nonASCIItoASCII[char]
switch {
case isCharMappedToASCII:
result.WriteRune(asciiChar)
} else if char > maxASCIIIndex {
case char > maxASCIIIndex:
// Don't emit char
} else {
default:
result.WriteRune(char)
}
}
Expand Down

0 comments on commit 19f0152

Please sign in to comment.