fast_blank_java 0.0.1-java → 0.0.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/benchmark.rb +11 -4
- data/ext/fast_blank_java/FastBlankJava.java +34 -6
- data/ext/fast_blank_java/FastBlankJavaService.java +2 -4
- data/lib/fast_blank_java.rb +1 -1
- data/lib/fast_blank_java/version.rb +1 -1
- data/lib/jars/fast_blank_java.jar +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec3dd8b44c891aa2b6e87b0abd1be712c085cac3
|
4
|
+
data.tar.gz: 44081f90b324b6d020c3daadebe9bb3f88fed5cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce4f876e96a59390d7934ce128d1d9a548ae52dfc6a80f7a144d4124d44109aba8be49c2d1729e8d765dd87e330579af154556d2f886c108ec6648aef524ac8
|
7
|
+
data.tar.gz: 4d41f078e365f4d4533936e5ad4d3808ef46d032f798d5cc8d686207fc0bb44a70faf8bd2fbc1c4b8bcbb31163d7aa5baadcf24bdcc36b214652de50d2b84722
|
data/benchmark.rb
CHANGED
@@ -25,9 +25,8 @@ test_strings = [
|
|
25
25
|
]
|
26
26
|
|
27
27
|
test_strings.each do |s|
|
28
|
-
raise "failed on #{s.inspect}" if s.blank? != s.slow_blank?
|
29
|
-
raise "failed on #{s.inspect}" if s.blank? != s.new_slow_blank?
|
30
|
-
raise "failed on #{s.inspect}" if s.blank? != s.fast_blank_java?
|
28
|
+
raise "failed on #{s.inspect} blank? => #{s.blank?} : slow_blank? => #{s.slow_blank?}" if s.blank? != s.slow_blank?
|
29
|
+
raise "failed on #{s.inspect} blank? => #{s.blank?} : new_slow_blank? => #{s.new_slow_blank?}" if s.blank? != s.new_slow_blank?
|
31
30
|
end
|
32
31
|
|
33
32
|
test_strings.each do |s|
|
@@ -36,7 +35,15 @@ test_strings.each do |s|
|
|
36
35
|
x.report("Fast Blank Java") do |times|
|
37
36
|
i = 0
|
38
37
|
while i < times
|
39
|
-
s.
|
38
|
+
s.blank?
|
39
|
+
i += 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
x.report("Fast Blank Java AS") do |times|
|
44
|
+
i = 0
|
45
|
+
while i < times
|
46
|
+
s.fast_blank_java_as?
|
40
47
|
i += 1
|
41
48
|
end
|
42
49
|
end
|
@@ -16,14 +16,12 @@ import org.jruby.runtime.ThreadContext;
|
|
16
16
|
import org.jruby.runtime.builtin.IRubyObject;
|
17
17
|
|
18
18
|
public class FastBlankJava {
|
19
|
-
@JRubyMethod(name = { "
|
19
|
+
@JRubyMethod(name = { "fast_blank_java_as?", "blank_as?" })
|
20
20
|
public static IRubyObject fast_blank_as_java_p(ThreadContext context, IRubyObject self) {
|
21
|
-
org.jruby.Ruby runtime = context.getRuntime();
|
22
|
-
|
23
21
|
if (self instanceof RubyString) {
|
24
22
|
org.jruby.RubyString rubyString = ((RubyString) self);
|
25
23
|
if (rubyString.isEmpty()) {
|
26
|
-
return
|
24
|
+
return context.tru;
|
27
25
|
}
|
28
26
|
|
29
27
|
ByteList blankValue = rubyString.getByteList();
|
@@ -67,15 +65,45 @@ public class FastBlankJava {
|
|
67
65
|
case 0x3000:
|
68
66
|
break;
|
69
67
|
default:
|
70
|
-
return
|
68
|
+
return context.fals;
|
71
69
|
}
|
72
70
|
|
73
71
|
next_char += len_p[0];
|
74
72
|
}
|
75
73
|
|
76
|
-
return
|
74
|
+
return context.tru;
|
77
75
|
}
|
78
76
|
|
79
77
|
throw context.getRuntime().newTypeError("can't #fast_blank_java? a non-string object");
|
80
78
|
}
|
79
|
+
|
80
|
+
public static boolean rb_isspace(int character) {
|
81
|
+
return character == ' ' || ('\t' <= character && character <= '\r');
|
82
|
+
}
|
83
|
+
|
84
|
+
@JRubyMethod(name = { "fast_blank_java?", "blank?" })
|
85
|
+
public static IRubyObject fast_blank_p(ThreadContext context, IRubyObject self) {
|
86
|
+
Encoding enc;
|
87
|
+
int s, e;
|
88
|
+
byte[] sBytes;
|
89
|
+
Ruby runtime = context.runtime;
|
90
|
+
RubyString str = (RubyString) self;
|
91
|
+
enc = str.getEncoding();
|
92
|
+
ByteList sByteList = str.getByteList();
|
93
|
+
sBytes = sByteList.unsafeBytes();
|
94
|
+
s = sByteList.begin();
|
95
|
+
if (str.size() == 0) return context.tru;
|
96
|
+
e = s + sByteList.realSize();
|
97
|
+
int[] n = {0};
|
98
|
+
int cc = 0;
|
99
|
+
|
100
|
+
while (s < e) {
|
101
|
+
cc = EncodingUtils.encCodepointLength(runtime, sBytes, s, e, n, enc);
|
102
|
+
if (!rb_isspace(cc) && cc != 0) { return context.fals; }
|
103
|
+
|
104
|
+
s += n[0];
|
105
|
+
}
|
106
|
+
|
107
|
+
return context.tru;
|
108
|
+
}
|
81
109
|
}
|
@@ -10,10 +10,8 @@ import java.io.IOException;
|
|
10
10
|
public class FastBlankJavaService implements BasicLibraryService {
|
11
11
|
@Override
|
12
12
|
public boolean basicLoad(final Ruby runtime) throws IOException {
|
13
|
-
RubyModule
|
14
|
-
|
15
|
-
RubyModule varinter = protobuf_java_helpers.defineModuleUnder(FastBlankJava.class.getSimpleName());
|
16
|
-
varinter.defineAnnotatedMethods(FastBlankJava.class);
|
13
|
+
RubyModule fast_blank_java = runtime.getModule("FastBlankJava");
|
14
|
+
fast_blank_java.defineAnnotatedMethods(FastBlankJava.class);
|
17
15
|
|
18
16
|
return true;
|
19
17
|
}
|
data/lib/fast_blank_java.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_blank_java
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Brandon Dewitt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|