sin_fast_blank 2.1.0-java → 2.2.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 +4 -4
- data/ext/java/sin_fast_blank/SinFastBlankLibrary.java +130 -86
- data/lib/sin_fast_blank/sin_fast_blank.jar +0 -0
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb9e8a93a0051213bd80b9c47b8247847a4d389e239715856c58335758dcbf8
|
4
|
+
data.tar.gz: b9b7d48920cd5c68dfd02e2ca3b87f98dffe3a45b195ac682429054aaed2b84b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00a76dcb482ecac9e61e7df4f675aec5863685652cc3adfc2cb0b35f8aee7b2b5e50bd3daa470d6bb94dddba59585df4ab6a6d2da63f130ce9ccc06d2c4c6b1c
|
7
|
+
data.tar.gz: 5999b81de14b1f220d3a6552d5c587c5d6dc5fbccd186978591ba6be1a9de16ebc533fabf428efa68700ff8e444daaae872bde5eec1f087ade27a0b51385b330
|
@@ -12,104 +12,148 @@ import org.jruby.util.StringSupport;
|
|
12
12
|
import org.jruby.util.io.EncodingUtils;
|
13
13
|
|
14
14
|
public class SinFastBlankLibrary implements Library {
|
15
|
-
|
16
|
-
runtime
|
17
|
-
|
18
|
-
|
19
|
-
@JRubyMethod(name = "blank_as?")
|
20
|
-
public static IRubyObject blank_as_p(ThreadContext context, IRubyObject self) {
|
21
|
-
RubyString str = (RubyString) self;
|
22
|
-
if (str.size() == 0) return context.tru;
|
23
|
-
|
24
|
-
Ruby runtime = context.runtime;
|
25
|
-
ByteList sByteList = str.getByteList();
|
26
|
-
byte[] sBytes = sByteList.unsafeBytes();
|
27
|
-
int s = sByteList.begin();
|
28
|
-
int e = s + sByteList.realSize();
|
29
|
-
int[] len = {0};
|
30
|
-
Encoding enc = str.getEncoding();
|
31
|
-
|
32
|
-
while (s < e) {
|
33
|
-
int codepoint = EncodingUtils.encCodepointLength(runtime, sBytes, s, e, len, enc);
|
34
|
-
|
35
|
-
switch (codepoint) {
|
36
|
-
case 9:
|
37
|
-
case 0xa:
|
38
|
-
case 0xb:
|
39
|
-
case 0xc:
|
40
|
-
case 0xd:
|
41
|
-
case 0x20:
|
42
|
-
case 0x85:
|
43
|
-
case 0xa0:
|
44
|
-
case 0x1680:
|
45
|
-
case 0x2000:
|
46
|
-
case 0x2001:
|
47
|
-
case 0x2002:
|
48
|
-
case 0x2003:
|
49
|
-
case 0x2004:
|
50
|
-
case 0x2005:
|
51
|
-
case 0x2006:
|
52
|
-
case 0x2007:
|
53
|
-
case 0x2008:
|
54
|
-
case 0x2009:
|
55
|
-
case 0x200a:
|
56
|
-
case 0x2028:
|
57
|
-
case 0x2029:
|
58
|
-
case 0x202f:
|
59
|
-
case 0x205f:
|
60
|
-
case 0x3000:
|
61
|
-
break;
|
62
|
-
default:
|
63
|
-
return context.fals;
|
64
|
-
}
|
65
|
-
|
66
|
-
s += len[0];
|
15
|
+
@Override
|
16
|
+
public void load(Ruby runtime, boolean wrap) {
|
17
|
+
runtime.getString().defineAnnotatedMethods(SinFastBlankLibrary.class);
|
67
18
|
}
|
68
19
|
|
69
|
-
|
70
|
-
|
20
|
+
@JRubyMethod(name = "blank_as?")
|
21
|
+
public static IRubyObject blank_as_p(ThreadContext context, IRubyObject self) {
|
22
|
+
RubyString str = (RubyString) self;
|
23
|
+
if (str.size() == 0) {
|
24
|
+
return context.tru;
|
25
|
+
}
|
26
|
+
|
27
|
+
ByteList sByteList = str.getByteList();
|
28
|
+
byte[] sBytes = sByteList.unsafeBytes();
|
29
|
+
int s = sByteList.begin();
|
30
|
+
int e = s + sByteList.realSize();
|
31
|
+
|
32
|
+
if (str.getCodeRange() == StringSupport.CR_7BIT) {
|
33
|
+
for (int i = s; i < e; i++) {
|
34
|
+
byte c = sBytes[i];
|
35
|
+
if (!isAsciiBlankAs(c)) {
|
36
|
+
return context.fals;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
return context.tru;
|
41
|
+
}
|
42
|
+
|
43
|
+
return blankAsSlow(context, sBytes, s, e, str.getEncoding());
|
44
|
+
}
|
71
45
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
+
}
|
58
|
+
}
|
76
59
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
int e = s + sByteList.realSize();
|
60
|
+
private static IRubyObject blankAsSlow(ThreadContext context, byte[] bytes, int s, int e, Encoding enc) {
|
61
|
+
Ruby runtime = context.runtime;
|
62
|
+
int[] len = {0};
|
81
63
|
|
82
|
-
|
83
|
-
|
64
|
+
while (s < e) {
|
65
|
+
int codepoint = EncodingUtils.encCodepointLength(runtime, bytes, s, e, len, enc);
|
84
66
|
|
85
|
-
|
86
|
-
|
87
|
-
|
67
|
+
if (!isUnicodeBlankAs(codepoint)) {
|
68
|
+
return context.fals;
|
69
|
+
}
|
88
70
|
|
89
|
-
|
90
|
-
|
71
|
+
s += len[0];
|
72
|
+
}
|
91
73
|
|
92
|
-
|
93
|
-
|
94
|
-
int[] len = {0};
|
74
|
+
return context.tru;
|
75
|
+
}
|
95
76
|
|
96
|
-
|
97
|
-
|
98
|
-
|
77
|
+
private static boolean isUnicodeBlankAs(int codepoint) {
|
78
|
+
switch (codepoint) {
|
79
|
+
case 0x9:
|
80
|
+
case 0xa:
|
81
|
+
case 0xb:
|
82
|
+
case 0xc:
|
83
|
+
case 0xd:
|
84
|
+
case 0x20:
|
85
|
+
case 0x85:
|
86
|
+
case 0xa0:
|
87
|
+
case 0x1680:
|
88
|
+
case 0x2000:
|
89
|
+
case 0x2001:
|
90
|
+
case 0x2002:
|
91
|
+
case 0x2003:
|
92
|
+
case 0x2004:
|
93
|
+
case 0x2005:
|
94
|
+
case 0x2006:
|
95
|
+
case 0x2007:
|
96
|
+
case 0x2008:
|
97
|
+
case 0x2009:
|
98
|
+
case 0x200a:
|
99
|
+
case 0x2028:
|
100
|
+
case 0x2029:
|
101
|
+
case 0x202f:
|
102
|
+
case 0x205f:
|
103
|
+
case 0x3000:
|
104
|
+
return true;
|
105
|
+
default:
|
106
|
+
return false;
|
107
|
+
}
|
108
|
+
}
|
99
109
|
|
100
|
-
|
110
|
+
@JRubyMethod(name = "blank?")
|
111
|
+
public static IRubyObject blank_p(ThreadContext context, IRubyObject self) {
|
112
|
+
RubyString str = (RubyString) self;
|
113
|
+
if (str.size() == 0) {
|
114
|
+
return context.tru;
|
115
|
+
}
|
116
|
+
|
117
|
+
ByteList sByteList = str.getByteList();
|
118
|
+
byte[] sBytes = sByteList.unsafeBytes();
|
119
|
+
int s = sByteList.begin();
|
120
|
+
int e = s + sByteList.realSize();
|
121
|
+
|
122
|
+
if (str.getCodeRange() == StringSupport.CR_7BIT) {
|
123
|
+
for (int i = s; i < e; i++) {
|
124
|
+
if (!isSpace(sBytes[i])) {
|
125
|
+
return context.fals;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
return context.tru;
|
130
|
+
}
|
131
|
+
|
132
|
+
return blankSlow(context, sBytes, s, e, str.getEncoding());
|
101
133
|
}
|
102
134
|
|
103
|
-
|
104
|
-
|
135
|
+
private static IRubyObject blankSlow(ThreadContext context, byte[] bytes, int s, int e, Encoding enc) {
|
136
|
+
Ruby runtime = context.runtime;
|
137
|
+
int[] len = {0};
|
138
|
+
|
139
|
+
while (s < e) {
|
140
|
+
int codepoint = EncodingUtils.encCodepointLength(runtime, bytes, s, e, len, enc);
|
105
141
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
return c == ' ' || ('\t' <= c && c <= '\r');
|
110
|
-
}
|
142
|
+
if (codepoint != 0 && !isSpaceCodepoint(codepoint)) {
|
143
|
+
return context.fals;
|
144
|
+
}
|
111
145
|
|
112
|
-
|
113
|
-
|
114
|
-
|
146
|
+
s += len[0];
|
147
|
+
}
|
148
|
+
|
149
|
+
return context.tru;
|
150
|
+
}
|
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
|
+
}
|
115
159
|
}
|
Binary file
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sin_fast_blank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.2.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Masahiro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
|
-
Ruby extension library for
|
14
|
+
Ruby extension library for up to 9x faster blank string checking than fast_blank gem.
|
15
15
|
Forked from FastBlank.
|
16
16
|
email:
|
17
17
|
- watanabe@cadenza-tech.com
|
@@ -21,15 +21,15 @@ extra_rdoc_files: []
|
|
21
21
|
files:
|
22
22
|
- ext/java/sin_fast_blank/SinFastBlankLibrary.java
|
23
23
|
- lib/sin_fast_blank/sin_fast_blank.jar
|
24
|
-
homepage: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.1
|
24
|
+
homepage: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.2.1
|
25
25
|
licenses:
|
26
26
|
- MIT
|
27
27
|
metadata:
|
28
|
-
homepage_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.1
|
29
|
-
source_code_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.1
|
30
|
-
changelog_uri: https://github.com/cadenza-tech/sin_fast_blank/blob/v2.1
|
28
|
+
homepage_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.2.1
|
29
|
+
source_code_uri: https://github.com/cadenza-tech/sin_fast_blank/tree/v2.2.1
|
30
|
+
changelog_uri: https://github.com/cadenza-tech/sin_fast_blank/blob/v2.2.1/CHANGELOG.md
|
31
31
|
bug_tracker_uri: https://github.com/cadenza-tech/sin_fast_blank/issues
|
32
|
-
documentation_uri: https://rubydoc.info/gems/sin_fast_blank/2.1
|
32
|
+
documentation_uri: https://rubydoc.info/gems/sin_fast_blank/2.2.1
|
33
33
|
funding_uri: https://patreon.com/CadenzaTech
|
34
34
|
rubygems_mfa_required: 'true'
|
35
35
|
required_jruby_version: ">= 9.3.0.0"
|
@@ -53,5 +53,6 @@ requirements: []
|
|
53
53
|
rubygems_version: 3.2.33
|
54
54
|
signing_key:
|
55
55
|
specification_version: 4
|
56
|
-
summary: Ruby extension library for
|
56
|
+
summary: Ruby extension library for up to 9x faster blank string checking than fast_blank
|
57
|
+
gem.
|
57
58
|
test_files: []
|