diff --git a/decoder.go b/decoder.go index a75168d..de32037 100644 --- a/decoder.go +++ b/decoder.go @@ -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) @@ -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) diff --git a/sse_amd64.go b/sse_amd64.go index 37fd4a5..0087091 100644 --- a/sse_amd64.go +++ b/sse_amd64.go @@ -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 -} diff --git a/sse_amd64_test.go b/sse_amd64_test.go index c4925f9..87de9ee 100644 --- a/sse_amd64_test.go +++ b/sse_amd64_test.go @@ -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)) -}