aboutsummaryrefslogtreecommitdiff
path: root/lib/ascii
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ascii')
-rw-r--r--lib/ascii/set.go4
-rw-r--r--lib/ascii/set_benchmark_test.go16
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/ascii/set.go b/lib/ascii/set.go
index 6e867287..1c813db9 100644
--- a/lib/ascii/set.go
+++ b/lib/ascii/set.go
@@ -106,8 +106,8 @@ func (as *Set) Equal(as2 Set) bool {
// the set in any other way.
func (as *Set) Visit(do func(n byte) (skip bool)) (aborted bool) {
var currentChar byte
- for i := uint(0); i < 4; i++ {
- for j := uint(0); j < 32; j++ {
+ for i := range uint(4) {
+ for j := range uint(32) {
if (as[i] & (1 << j)) != 0 {
if do(currentChar) {
return true
diff --git a/lib/ascii/set_benchmark_test.go b/lib/ascii/set_benchmark_test.go
index 53194daa..030ef82d 100644
--- a/lib/ascii/set_benchmark_test.go
+++ b/lib/ascii/set_benchmark_test.go
@@ -22,7 +22,7 @@ const N int = 10
// if populate is true, fill each set with every 2nd ASCII character
func setupSets(populate bool) []Set {
sets := []Set{}
- for i := 0; i < N; i++ {
+ for range N {
var as Set
if populate {
for c := 0; c < utf8.RuneSelf; c += 2 {
@@ -41,7 +41,7 @@ func setupSets(populate bool) []Set {
// if populate is true, fill each set with every 2nd ASCII character
func setupMapSets(populate bool) []map[byte]struct{} {
sets := []map[byte]struct{}{}
- for i := 0; i < N; i++ {
+ for range N {
as := make(map[byte]struct{})
if populate {
for c := 0; c < utf8.RuneSelf; c += 2 {
@@ -73,7 +73,7 @@ func BenchmarkSet(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, as := range sets {
- for c := byte(0); c < utf8.RuneSelf; c++ {
+ for c := range byte(utf8.RuneSelf) {
exists = as.Contains(c)
}
}
@@ -85,7 +85,7 @@ func BenchmarkSet(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, as := range sets {
- for c := byte(0); c < utf8.RuneSelf; c++ {
+ for c := range byte(utf8.RuneSelf) {
as.Remove(c)
}
}
@@ -97,7 +97,7 @@ func BenchmarkSet(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, as := range sets {
- for c := byte(0); c < utf8.RuneSelf; c++ {
+ for range byte(utf8.RuneSelf) {
size = as.Size()
}
}
@@ -139,7 +139,7 @@ func BenchmarkMapSet(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, as := range sets {
- for c := byte(0); c < utf8.RuneSelf; c++ {
+ for c := range byte(utf8.RuneSelf) {
_, exists = as[c]
}
}
@@ -151,7 +151,7 @@ func BenchmarkMapSet(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, as := range sets {
- for c := byte(0); c < utf8.RuneSelf; c++ {
+ for c := range byte(utf8.RuneSelf) {
delete(as, c)
}
}
@@ -163,7 +163,7 @@ func BenchmarkMapSet(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, as := range sets {
- for c := byte(0); c < utf8.RuneSelf; c++ {
+ for range byte(utf8.RuneSelf) {
size = len(as)
}
}