sin_fast_blank 2.1.0 → 2.2.1
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/sin_fast_blank/sin_fast_blank.c +98 -43
- 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: 6ad6214a69fa114a91b0c5356d1b1f5340a3ce612394c0663c08414c90b15221
|
4
|
+
data.tar.gz: 9d457aa4e5fdbeb5a265036106c69970dab46dd257cbe5712eaf9dc4607b82de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb488aa80d5adc45345ac5ee012816028e3ff0cc3fc04d443dabc37dc22b68037c5049531eb9f542e3d77399c55f8380e17987d8478e2661713dce68c52cf61f
|
7
|
+
data.tar.gz: e7bd3ae5809e552290ac2e568d33f863c5cb02a195ef7a78c24ba373c82a11d33df84b4e54d46f053f2d98e534a5877ebc0f0127653ecd9ca072d22101236e2a
|
@@ -3,67 +3,122 @@
|
|
3
3
|
|
4
4
|
#define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
|
5
5
|
|
6
|
+
static inline int is_unicode_blank(unsigned int codepoint) {
|
7
|
+
switch (codepoint) {
|
8
|
+
case 0x9:
|
9
|
+
case 0xa:
|
10
|
+
case 0xb:
|
11
|
+
case 0xc:
|
12
|
+
case 0xd:
|
13
|
+
case 0x20:
|
14
|
+
case 0x85:
|
15
|
+
case 0xa0:
|
16
|
+
case 0x1680:
|
17
|
+
case 0x2000:
|
18
|
+
case 0x2001:
|
19
|
+
case 0x2002:
|
20
|
+
case 0x2003:
|
21
|
+
case 0x2004:
|
22
|
+
case 0x2005:
|
23
|
+
case 0x2006:
|
24
|
+
case 0x2007:
|
25
|
+
case 0x2008:
|
26
|
+
case 0x2009:
|
27
|
+
case 0x200a:
|
28
|
+
case 0x2028:
|
29
|
+
case 0x2029:
|
30
|
+
case 0x202f:
|
31
|
+
case 0x205f:
|
32
|
+
case 0x3000:
|
33
|
+
return 1;
|
34
|
+
default:
|
35
|
+
return 0;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
6
39
|
static VALUE rb_str_blank_as(VALUE str) {
|
7
|
-
|
8
|
-
if (
|
40
|
+
long len = RSTRING_LEN(str);
|
41
|
+
if (len == 0) {
|
42
|
+
return Qtrue;
|
43
|
+
}
|
9
44
|
|
10
|
-
char *
|
45
|
+
const char *ptr = RSTRING_PTR(str);
|
46
|
+
const char *end = ptr + len;
|
11
47
|
rb_encoding *enc = STR_ENC_GET(str);
|
12
48
|
|
49
|
+
if (rb_enc_asciicompat(enc)) {
|
50
|
+
for (const unsigned char *p = (const unsigned char *)ptr; p < (const unsigned char *)end; p++) {
|
51
|
+
if (*p >= 0x80) {
|
52
|
+
goto FULL_CHECK;
|
53
|
+
}
|
54
|
+
|
55
|
+
switch (*p) {
|
56
|
+
case 0x9:
|
57
|
+
case 0xa:
|
58
|
+
case 0xb:
|
59
|
+
case 0xc:
|
60
|
+
case 0xd:
|
61
|
+
case 0x20:
|
62
|
+
break;
|
63
|
+
default:
|
64
|
+
return Qfalse;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
return Qtrue;
|
69
|
+
}
|
70
|
+
|
71
|
+
FULL_CHECK:;
|
13
72
|
while (ptr < end) {
|
14
|
-
int
|
15
|
-
unsigned int codepoint = rb_enc_codepoint_len(ptr, end, &
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
case 0xa:
|
20
|
-
case 0xb:
|
21
|
-
case 0xc:
|
22
|
-
case 0xd:
|
23
|
-
case 0x20:
|
24
|
-
case 0x85:
|
25
|
-
case 0xa0:
|
26
|
-
case 0x1680:
|
27
|
-
case 0x2000:
|
28
|
-
case 0x2001:
|
29
|
-
case 0x2002:
|
30
|
-
case 0x2003:
|
31
|
-
case 0x2004:
|
32
|
-
case 0x2005:
|
33
|
-
case 0x2006:
|
34
|
-
case 0x2007:
|
35
|
-
case 0x2008:
|
36
|
-
case 0x2009:
|
37
|
-
case 0x200a:
|
38
|
-
case 0x2028:
|
39
|
-
case 0x2029:
|
40
|
-
case 0x202f:
|
41
|
-
case 0x205f:
|
42
|
-
case 0x3000:
|
43
|
-
break;
|
44
|
-
default:
|
45
|
-
return Qfalse;
|
73
|
+
int clen;
|
74
|
+
unsigned int codepoint = rb_enc_codepoint_len(ptr, end, &clen, enc);
|
75
|
+
|
76
|
+
if (!is_unicode_blank(codepoint)) {
|
77
|
+
return Qfalse;
|
46
78
|
}
|
47
79
|
|
48
|
-
ptr +=
|
80
|
+
ptr += clen;
|
49
81
|
}
|
50
82
|
|
51
83
|
return Qtrue;
|
52
84
|
}
|
53
85
|
|
54
86
|
static VALUE rb_str_blank(VALUE str) {
|
55
|
-
|
56
|
-
if (
|
87
|
+
long len = RSTRING_LEN(str);
|
88
|
+
if (len == 0) {
|
89
|
+
return Qtrue;
|
90
|
+
}
|
57
91
|
|
58
|
-
char *
|
92
|
+
const char *ptr = RSTRING_PTR(str);
|
93
|
+
const char *end = ptr + len;
|
59
94
|
rb_encoding *enc = STR_ENC_GET(str);
|
95
|
+
|
96
|
+
if (rb_enc_asciicompat(enc)) {
|
97
|
+
for (; ptr < end; ptr++) {
|
98
|
+
unsigned char c = (unsigned char)*ptr;
|
99
|
+
|
100
|
+
if (c >= 0x80) {
|
101
|
+
goto FULL_CHECK;
|
102
|
+
}
|
103
|
+
|
104
|
+
if (!rb_isspace(c) && c != 0) {
|
105
|
+
return Qfalse;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
return Qtrue;
|
110
|
+
}
|
111
|
+
|
112
|
+
FULL_CHECK:;
|
60
113
|
while (ptr < end) {
|
61
|
-
int
|
62
|
-
unsigned int codepoint = rb_enc_codepoint_len(ptr, end, &
|
114
|
+
int clen;
|
115
|
+
unsigned int codepoint = rb_enc_codepoint_len(ptr, end, &clen, enc);
|
63
116
|
|
64
|
-
if (
|
117
|
+
if (codepoint != 0 && !rb_isspace(codepoint)) {
|
118
|
+
return Qfalse;
|
119
|
+
}
|
65
120
|
|
66
|
-
ptr +=
|
121
|
+
ptr += clen;
|
67
122
|
}
|
68
123
|
|
69
124
|
return Qtrue;
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
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: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: |
|
13
|
-
Ruby extension library for
|
13
|
+
Ruby extension library for up to 9x faster blank string checking than fast_blank gem.
|
14
14
|
Forked from FastBlank.
|
15
15
|
email:
|
16
16
|
- watanabe@cadenza-tech.com
|
@@ -21,15 +21,15 @@ extra_rdoc_files: []
|
|
21
21
|
files:
|
22
22
|
- ext/sin_fast_blank/extconf.rb
|
23
23
|
- ext/sin_fast_blank/sin_fast_blank.c
|
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"
|
@@ -51,5 +51,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements: []
|
52
52
|
rubygems_version: 3.6.2
|
53
53
|
specification_version: 4
|
54
|
-
summary: Ruby extension library for
|
54
|
+
summary: Ruby extension library for up to 9x faster blank string checking than fast_blank
|
55
|
+
gem.
|
55
56
|
test_files: []
|