Skip to content

Commit

Permalink
Inline onlySpacesUntil16/32 functions
Browse files Browse the repository at this point in the history
There is no real value in having these functions.
Readability is not really improved by them.
  • Loading branch information
kaiburjack committed Aug 17, 2022
1 parent 622ec16 commit ce4c507
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
4 changes: 2 additions & 2 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func (thiz *decoder) decodeTextSSE(t *Token) (bool, error) {
c := 0
for thiz.w > thiz.r+c {
sidx := openAngleBracket16(thiz.rb[j+c : thiz.w])
onlyWhitespaces = onlyWhitespaces && onlySpacesUntil16(thiz.rb[j+c:thiz.w], sidx)
onlyWhitespaces = onlyWhitespaces && onlySpaces16(thiz.rb[j+c:thiz.w]) >= sidx
c += int(sidx)
if sidx != 16 {
_, err := thiz.discard(c)
Expand Down Expand Up @@ -453,7 +453,7 @@ func (thiz *decoder) decodeTextAVX2(t *Token) (bool, error) {
c := 0
for thiz.w > thiz.r+c {
sidx := openAngleBracket32(thiz.rb[j+c : thiz.w])
onlyWhitespaces = onlyWhitespaces && onlySpacesUntil32(thiz.rb[j+c:thiz.w], sidx)
onlyWhitespaces = onlyWhitespaces && onlySpaces32(thiz.rb[j+c:thiz.w]) >= sidx
c += int(sidx)
if sidx != 32 {
_, err := thiz.discard(c)
Expand Down
8 changes: 0 additions & 8 deletions sse_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ func openAngleBracket16([]uint8) byte
//go:noescape
func onlySpaces16([]uint8) byte

func onlySpacesUntil16(slice []uint8, n byte) bool {
return onlySpaces16(slice) >= n
}

//go:noescape
func openAngleBracket32([]uint8) byte

//go:noescape
func onlySpaces32([]uint8) byte

func onlySpacesUntil32(slice []uint8, n byte) bool {
return onlySpaces32(slice) >= n
}
12 changes: 0 additions & 12 deletions sse_amd64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,3 @@ func TestOnlySpaces32(t *testing.T) {
assert.Equal(t, byte(3), onlySpaces32([]uint8{0x20, 0x20, 0x20, 0xC2, 0xA7, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}))
assert.Equal(t, byte(32), onlySpaces32([]uint8{0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}))
}

func TestOnlySpacesUntil16(t *testing.T) {
assert.True(t, onlySpacesUntil16([]uint8{0x20, 0x20, 0x20, 0xC2, 0xA7, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, 3))
assert.True(t, onlySpacesUntil16([]uint8{0x20, 0x20, 0x20, 0xC2, 0xA7, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, 2))
assert.False(t, onlySpacesUntil16([]uint8{0x20, 0x20, 0x20, 0xC2, 0xA7, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, 4))
}

func TestOnlySpacesUntil32(t *testing.T) {
assert.True(t, onlySpacesUntil32([]uint8{0x20, 0x20, 0x20, 0xC2, 0xA7, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, 3))
assert.True(t, onlySpacesUntil32([]uint8{0x20, 0x20, 0x20, 0xC2, 0xA7, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, 2))
assert.False(t, onlySpacesUntil32([]uint8{0x20, 0x20, 0x20, 0xC2, 0xA7, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, 4))
}

0 comments on commit ce4c507

Please sign in to comment.