xorcist 1.0.1 → 1.1.0
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/README.md +2 -1
- data/ext/xorcist/extconf.rb +1 -1
- data/ext/xorcist/xorcist.c +11 -1
- data/lib/xorcist.rb +16 -2
- data/lib/xorcist/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e60583bfba07126835c5def71dbfd1997f504a22
|
4
|
+
data.tar.gz: 13cf6b74ab9ea7ae040148ce130e24665c73bd25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 391f4eae4f0422e52ad1e52ddd500f23c23373a4a1d2c8e5004c70dc3a4f21364e8d9e3fedfc4fabb2bf8a31e72129477fdca5efb0709f136005eecfcaaff99a
|
7
|
+
data.tar.gz: 7d884189cb4f58d98ce01a6dd72ff97d1e95507c292f3960f7b345220c3e87af040eb5cd57800cb147fe7122e6c636b01b6349843e43092ed7546962ff1260bb
|
data/README.md
CHANGED
@@ -15,6 +15,7 @@ Xorcist.xor(a, b) # => "\u0003"
|
|
15
15
|
a # => 'a'
|
16
16
|
Xorcist.xor!(a, b) # => "\u0003"
|
17
17
|
a # => "\u0003"
|
18
|
+
Xorcist.xor!(a.freeze, b) # => RuntimeError!
|
18
19
|
```
|
19
20
|
|
20
21
|
You can `include Xorcist` to expose its methods:
|
@@ -70,7 +71,7 @@ Calculating -------------------------------------
|
|
70
71
|
### JRuby 1.7.19
|
71
72
|
|
72
73
|
```
|
73
|
-
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
|
74
|
+
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
|
74
75
|
Calculating -------------------------------------
|
75
76
|
ruby 31.795k i/100ms
|
76
77
|
xorcist 118.084k i/100ms
|
data/ext/xorcist/extconf.rb
CHANGED
data/ext/xorcist/xorcist.c
CHANGED
@@ -4,7 +4,7 @@ VALUE Xorcist = Qnil;
|
|
4
4
|
|
5
5
|
void Init_xorcist();
|
6
6
|
|
7
|
-
VALUE xor_in_place(VALUE
|
7
|
+
VALUE xor_in_place(VALUE self, VALUE x, VALUE y);
|
8
8
|
|
9
9
|
VALUE xor_in_place(VALUE self, VALUE x, VALUE y) {
|
10
10
|
const char *src = 0;
|
@@ -12,6 +12,16 @@ VALUE xor_in_place(VALUE self, VALUE x, VALUE y) {
|
|
12
12
|
size_t len;
|
13
13
|
size_t y_len;
|
14
14
|
|
15
|
+
if (TYPE(x) != T_STRING) {
|
16
|
+
rb_raise( rb_eTypeError, "first argument must be a String" );
|
17
|
+
return Qnil;
|
18
|
+
}
|
19
|
+
|
20
|
+
if (TYPE(y) != T_STRING) {
|
21
|
+
rb_raise( rb_eTypeError, "second argument must be a String" );
|
22
|
+
return Qnil;
|
23
|
+
}
|
24
|
+
|
15
25
|
rb_str_modify(x);
|
16
26
|
dest = RSTRING_PTR(x);
|
17
27
|
len = RSTRING_LEN(x);
|
data/lib/xorcist.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'xorcist/version'
|
2
2
|
|
3
3
|
if RUBY_ENGINE == 'jruby'
|
4
|
-
require '
|
4
|
+
require 'java'
|
5
5
|
require File.expand_path('../xorcist.jar', __FILE__)
|
6
6
|
else
|
7
|
-
require
|
7
|
+
require 'xorcist/xorcist'
|
8
8
|
end
|
9
9
|
|
10
10
|
module Xorcist
|
@@ -12,4 +12,18 @@ module Xorcist
|
|
12
12
|
def xor(x, y)
|
13
13
|
xor!(x.dup, y)
|
14
14
|
end
|
15
|
+
|
16
|
+
# rb_str_modify isn't blowing up for frozen strings under Rubinius, so we'll
|
17
|
+
# hack in a fix here
|
18
|
+
if RUBY_ENGINE == 'rbx'
|
19
|
+
alias_method :_xor!, :xor!
|
20
|
+
remove_method :xor!
|
21
|
+
def xor!(x, y)
|
22
|
+
if x.frozen?
|
23
|
+
raise(RuntimeError, "can't modify frozen String")
|
24
|
+
else
|
25
|
+
_xor!(x, y)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
15
29
|
end
|
data/lib/xorcist/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xorcist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Faraz Yashar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
104
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.6.11
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Blazing-fast-cross-platform-monkey-patch-free string XOR
|