sin_fast_blank 3.1.1-java → 4.0.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d4e851d2fe91cf3500ea48e4b3f6b2b7f7102220f5cdd749d2d0f40ce771d6e8
|
|
4
|
+
data.tar.gz: a43c4b3688dfccd11fd98014eb9504c6da4063b94093462fdf3cd0cac9652c74
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dcb74483cca8c2a4af589d2f1ce7ac35babb1fadbf9b0a5a46c42e8fa22c29ecc7db57f54914360b6546d0ec0bb6b02cf9ca2e3757e35f4170e35a5278c59b8d
|
|
7
|
+
data.tar.gz: 60268c8edccd06b9c83d6304e06a7cec3688f32f6f0bd67fd5fd18fdabbceb547ebe8315ef95a0e5ef1f6f52dabd8313cb31d20929f655011197ce842ac7e83e
|
|
@@ -8,7 +8,6 @@ import org.jruby.runtime.ThreadContext;
|
|
|
8
8
|
import org.jruby.runtime.builtin.IRubyObject;
|
|
9
9
|
import org.jruby.runtime.load.Library;
|
|
10
10
|
import org.jruby.util.ByteList;
|
|
11
|
-
import org.jruby.util.StringSupport;
|
|
12
11
|
import org.jruby.util.io.EncodingUtils;
|
|
13
12
|
|
|
14
13
|
public class SinFastBlankLibrary implements Library {
|
|
@@ -20,61 +19,37 @@ public class SinFastBlankLibrary implements Library {
|
|
|
20
19
|
@JRubyMethod(name = "blank?")
|
|
21
20
|
public static IRubyObject blank_p(ThreadContext context, IRubyObject self) {
|
|
22
21
|
RubyString str = (RubyString) self;
|
|
23
|
-
|
|
22
|
+
ByteList byteList = str.getByteList();
|
|
23
|
+
if (byteList.realSize() == 0) {
|
|
24
24
|
return context.tru;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
int
|
|
30
|
-
|
|
27
|
+
byte[] bytes = byteList.unsafeBytes();
|
|
28
|
+
int s = byteList.begin();
|
|
29
|
+
int e = s + byteList.realSize();
|
|
30
|
+
Encoding enc = str.getEncoding();
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (enc.isAsciiCompatible()) {
|
|
33
33
|
for (int i = s; i < e; i++) {
|
|
34
|
-
byte c =
|
|
35
|
-
if (
|
|
34
|
+
byte c = bytes[i];
|
|
35
|
+
if (c < 0) {
|
|
36
|
+
return blankUnicodeSlow(context, bytes, i, e, enc);
|
|
37
|
+
}
|
|
38
|
+
if (!isAsciiBlank(c)) {
|
|
36
39
|
return context.fals;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
|
-
|
|
40
42
|
return context.tru;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private static boolean isAsciiBlankAs(byte c) {
|
|
47
|
-
switch (c) {
|
|
48
|
-
case 0x9:
|
|
49
|
-
case 0xa:
|
|
50
|
-
case 0xb:
|
|
51
|
-
case 0xc:
|
|
52
|
-
case 0xd:
|
|
53
|
-
case 0x20:
|
|
54
|
-
return true;
|
|
55
|
-
default:
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
45
|
+
return blankUnicodeSlow(context, bytes, s, e, enc);
|
|
58
46
|
}
|
|
59
47
|
|
|
60
|
-
private static
|
|
61
|
-
|
|
62
|
-
int[] len = {0};
|
|
63
|
-
|
|
64
|
-
while (s < e) {
|
|
65
|
-
int codepoint = EncodingUtils.encCodepointLength(runtime, bytes, s, e, len, enc);
|
|
66
|
-
|
|
67
|
-
if (!isUnicodeBlankAs(codepoint)) {
|
|
68
|
-
return context.fals;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
s += len[0];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return context.tru;
|
|
48
|
+
private static boolean isAsciiBlank(byte c) {
|
|
49
|
+
return (c >= 0x09 && c <= 0x0d) || c == 0x20;
|
|
75
50
|
}
|
|
76
51
|
|
|
77
|
-
private static boolean
|
|
52
|
+
private static boolean isUnicodeBlank(int codepoint) {
|
|
78
53
|
switch (codepoint) {
|
|
79
54
|
case 0x9:
|
|
80
55
|
case 0xa:
|
|
@@ -107,53 +82,72 @@ public class SinFastBlankLibrary implements Library {
|
|
|
107
82
|
}
|
|
108
83
|
}
|
|
109
84
|
|
|
85
|
+
private static IRubyObject blankUnicodeSlow(
|
|
86
|
+
ThreadContext context, byte[] bytes, int s, int e, Encoding enc) {
|
|
87
|
+
Ruby runtime = context.runtime;
|
|
88
|
+
int[] len = {0};
|
|
89
|
+
|
|
90
|
+
while (s < e) {
|
|
91
|
+
int codepoint = EncodingUtils.encCodepointLength(runtime, bytes, s, e, len, enc);
|
|
92
|
+
if (!isUnicodeBlank(codepoint)) {
|
|
93
|
+
return context.fals;
|
|
94
|
+
}
|
|
95
|
+
s += len[0];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return context.tru;
|
|
99
|
+
}
|
|
100
|
+
|
|
110
101
|
@JRubyMethod(name = "ascii_blank?")
|
|
111
102
|
public static IRubyObject ascii_blank_p(ThreadContext context, IRubyObject self) {
|
|
112
103
|
RubyString str = (RubyString) self;
|
|
113
|
-
|
|
104
|
+
ByteList byteList = str.getByteList();
|
|
105
|
+
if (byteList.realSize() == 0) {
|
|
114
106
|
return context.tru;
|
|
115
107
|
}
|
|
116
108
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
int
|
|
120
|
-
|
|
109
|
+
byte[] bytes = byteList.unsafeBytes();
|
|
110
|
+
int s = byteList.begin();
|
|
111
|
+
int e = s + byteList.realSize();
|
|
112
|
+
Encoding enc = str.getEncoding();
|
|
121
113
|
|
|
122
|
-
if (
|
|
114
|
+
if (enc.isAsciiCompatible()) {
|
|
123
115
|
for (int i = s; i < e; i++) {
|
|
124
|
-
|
|
116
|
+
byte c = bytes[i];
|
|
117
|
+
if (c < 0) {
|
|
118
|
+
return asciiBlankUnicodeSlow(context, bytes, i, e, enc);
|
|
119
|
+
}
|
|
120
|
+
if (!isAsciiBlankOrNull(c)) {
|
|
125
121
|
return context.fals;
|
|
126
122
|
}
|
|
127
123
|
}
|
|
128
|
-
|
|
129
124
|
return context.tru;
|
|
130
125
|
}
|
|
131
126
|
|
|
132
|
-
return
|
|
127
|
+
return asciiBlankUnicodeSlow(context, bytes, s, e, enc);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private static boolean isAsciiBlankOrNull(byte c) {
|
|
131
|
+
return c == 0 || (c >= 0x09 && c <= 0x0d) || c == 0x20;
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
private static
|
|
134
|
+
private static boolean isAsciiSpace(int codepoint) {
|
|
135
|
+
return codepoint == ' ' || ('\t' <= codepoint && codepoint <= '\r');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private static IRubyObject asciiBlankUnicodeSlow(
|
|
139
|
+
ThreadContext context, byte[] bytes, int s, int e, Encoding enc) {
|
|
136
140
|
Ruby runtime = context.runtime;
|
|
137
141
|
int[] len = {0};
|
|
138
142
|
|
|
139
143
|
while (s < e) {
|
|
140
144
|
int codepoint = EncodingUtils.encCodepointLength(runtime, bytes, s, e, len, enc);
|
|
141
|
-
|
|
142
|
-
if (codepoint != 0 && !isSpaceCodepoint(codepoint)) {
|
|
145
|
+
if (codepoint != 0 && !isAsciiSpace(codepoint)) {
|
|
143
146
|
return context.fals;
|
|
144
147
|
}
|
|
145
|
-
|
|
146
148
|
s += len[0];
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
return context.tru;
|
|
150
152
|
}
|
|
151
|
-
|
|
152
|
-
private static boolean isSpaceCodepoint(int codepoint) {
|
|
153
|
-
return codepoint == ' ' || ('\t' <= codepoint && codepoint <= '\r');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
private static boolean isSpace(byte c) {
|
|
157
|
-
return c == ' ' || ('\t' <= c && c <= '\r') || c == '\0';
|
|
158
|
-
}
|
|
159
153
|
}
|
|
Binary file
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sin_fast_blank
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.1
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Masahiro
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Check for blank string faster than FastBlank or ActiveSupport
|
|
14
14
|
email:
|
|
@@ -19,15 +19,15 @@ extra_rdoc_files: []
|
|
|
19
19
|
files:
|
|
20
20
|
- ext/java/sin_fast_blank/SinFastBlankLibrary.java
|
|
21
21
|
- lib/sin_fast_blank/sin_fast_blank.jar
|
|
22
|
-
homepage: https://github.com/cadenza-tech/sin_fast_blank/tree/
|
|
22
|
+
homepage: https://github.com/cadenza-tech/sin_fast_blank/tree/v4.0.1
|
|
23
23
|
licenses:
|
|
24
24
|
- MIT
|
|
25
25
|
metadata:
|
|
26
|
-
homepage_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/
|
|
27
|
-
source_code_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/
|
|
28
|
-
changelog_uri: https://github.com/cadenza-tech/sin_fast_blank/blob/
|
|
26
|
+
homepage_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v4.0.1
|
|
27
|
+
source_code_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v4.0.1
|
|
28
|
+
changelog_uri: https://github.com/cadenza-tech/sin_fast_blank/blob/v4.0.1/CHANGELOG.md
|
|
29
29
|
bug_tracker_uri: https://github.com/cadenza-tech/sin_fast_blank/issues
|
|
30
|
-
documentation_uri: https://rubydoc.info/gems/sin_fast_blank/
|
|
30
|
+
documentation_uri: https://rubydoc.info/gems/sin_fast_blank/4.0.1
|
|
31
31
|
funding_uri: https://patreon.com/CadenzaTech
|
|
32
32
|
rubygems_mfa_required: 'true'
|
|
33
33
|
required_jruby_version: ">= 9.3.0.0"
|