xorcist 1.1.0 → 1.1.3

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
- SHA1:
3
- metadata.gz: e60583bfba07126835c5def71dbfd1997f504a22
4
- data.tar.gz: 13cf6b74ab9ea7ae040148ce130e24665c73bd25
2
+ SHA256:
3
+ metadata.gz: 6ee6808ecd35a87100601f25ef22c045cda8fe6f539aaaacc00f98181c49382b
4
+ data.tar.gz: 17f178c142385f7a22ec43afa01052436bc76f4df57108444f034ffa5d9012d5
5
5
  SHA512:
6
- metadata.gz: 391f4eae4f0422e52ad1e52ddd500f23c23373a4a1d2c8e5004c70dc3a4f21364e8d9e3fedfc4fabb2bf8a31e72129477fdca5efb0709f136005eecfcaaff99a
7
- data.tar.gz: 7d884189cb4f58d98ce01a6dd72ff97d1e95507c292f3960f7b345220c3e87af040eb5cd57800cb147fe7122e6c636b01b6349843e43092ed7546962ff1260bb
6
+ metadata.gz: d36cf607ff0bc2ca680449ab51af0f6efa513dbef36f814d33b54ca9d94e3b7d3df7a8514246397e81874f23a38cdc4e9e2479f5bcd26f64dd3f0cbc69d95496
7
+ data.tar.gz: 42cc8a921af0cadbbb9bb0a858a8d2ba9f0ebc3d77640c6d37fe70bfaa959336130798f983baba04eaf73a4d53d30f68420651f4632e0f756893c82400bec899
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Xorcist :ghost:
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/xorcist.svg)](http://badge.fury.io/rb/xorcist)
4
- [![Build Status](https://travis-ci.org/fny/xorcist.svg?branch=master)](https://travis-ci.org/fny/xorcist)
4
+ [![Test](https://github.com/fny/xorcist/actions/workflows/test.yml/badge.svg)](https://github.com/fny/xorcist/actions/workflows/test.yml)
5
5
 
6
6
  Blazing-fast-cross-platform-monkey-patch-free string XOR. Yes, that means JRuby too.
7
7
 
8
+ Supported platforms: MRI (v2+), JRuby (v9.2+), Truffle (v21+), Truffle+GraalVM (v21+).
9
+
8
10
  ## Usage
9
11
 
10
12
  ```ruby
@@ -41,6 +43,8 @@ a.xor(b)
41
43
  a.xor!(b)
42
44
  ```
43
45
 
46
+ Note: Refinements will not work in [JRuby 9.2.6](https://github.com/jruby/jruby/issues/5288) and below. This isn't an issue for earlier versions of JRuby 9.0-9.1 or JRuby 9.2.7+.
47
+
44
48
  You can also monkey patch `String` if you're into that:
45
49
 
46
50
  ```ruby
@@ -51,33 +55,36 @@ String.include(Xorcist::StringMethods)
51
55
 
52
56
  ## Encodings
53
57
 
54
- Note the precise encoding `xor`'s output is undefined in the v1.0.x releases. In MRI `xor!` will return a string using your default encoding. With JRuby, `xor!` will return an ASCII-8BIT string.
58
+ Note the precise encoding `xor`'s output is undefined in the v1.0-1.x releases. In MRI `xor!` will return a string using your default encoding. With JRuby, `xor!` will return an ASCII-8BIT string.
55
59
 
56
60
  ## Benchmarks
57
61
 
58
- Disclaimer: these are run from my craptop. Run 'em yourself with `bin/benchmark`. You'll need to have [`benchmark-ips`](https://github.com/evanphx/benchmark-ips) installed.
62
+ Run from my Macbook. Run 'em yourself with `bin/benchmark`. You'll need to have [`benchmark-ips`](https://github.com/evanphx/benchmark-ips) installed.
59
63
 
60
- ### MRI 2.2.1
64
+ ### MRI
61
65
 
62
66
  ```
67
+ ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
68
+
69
+ Warming up --------------------------------------
70
+ ruby 91.478k i/100ms
71
+ xorcist 1.043M i/100ms
63
72
  Calculating -------------------------------------
64
- ruby 26.378k i/100ms
65
- xorcist 73.291k i/100ms
66
- -------------------------------------------------
67
- ruby 376.513k (± 0.5%) i/s - 1.899M
68
- xorcist 2.150M (± 3.9%) i/s - 10.774M
73
+ ruby 928.443k (± 2.0%) i/s - 4.665M in 5.026920s
74
+ xorcist 10.438M (± 1.4%) i/s - 53.187M in 5.096610s
69
75
  ```
70
76
 
71
- ### JRuby 1.7.19
77
+ ### JRuby
72
78
 
73
79
  ```
74
- Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
80
+ jruby 9.3.6.0 (2.6.8) 2022-06-27 7a2cbcd376 OpenJDK 64-Bit Server VM 18.0.2+0 on 18.0.2+0 +jit [arm64-darwin]
81
+
82
+ Warming up --------------------------------------
83
+ ruby 236.487k i/100ms
84
+ xorcist 813.234k i/100ms
75
85
  Calculating -------------------------------------
76
- ruby 31.795k i/100ms
77
- xorcist 118.084k i/100ms
78
- -------------------------------------------------
79
- ruby 978.078k (±11.2%) i/s - 4.801M
80
- xorcist 3.897M (±14.1%) i/s - 19.012M
86
+ ruby 2.673M (±11.0%) i/s - 13.243M in 5.025536s
87
+ xorcist 20.432M (±24.4%) i/s - 90.269M in 5.000974s
81
88
  ```
82
89
 
83
90
  ## Installation
@@ -98,7 +105,7 @@ Or install it yourself as:
98
105
 
99
106
  ## Contributing
100
107
 
101
- Bug reports and pull requests are welcome on GitHub at https://github.com/fny/xorcist. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
108
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fny/xorcist.
102
109
 
103
110
  ## License
104
111
 
@@ -109,5 +116,5 @@ The gem is available as open source under the terms of the [MIT License](http://
109
116
  - [Steve Sloan](http://www.finagle.org) for his [fast_xor gem](https://github.com/CodeMonkeySteve/fast_xor) from which most of the tests are borrowed
110
117
  - [James Coglan](http://jcoglan.com) for his [guide on writing a JRuby Java extension](https://blog.jcoglan.com/2012/08/02/your-first-ruby-native-extension-java/)
111
118
  - [Thomas Leitner](https://github.com/gettalong) for a faster pure Ruby XOR implementation that's used in the benchmark
119
+ - [The JRuby Team](https://twitter.com/jruby) for their assistance in debugging various issues over the years
112
120
  - To all [contributers](https://github.com/fny/xorcist/graphs/contributors)! :beers:
113
-
@@ -1,26 +1,13 @@
1
1
  #include <ruby.h>
2
2
 
3
- VALUE Xorcist = Qnil;
4
-
5
- void Init_xorcist();
6
-
7
- VALUE xor_in_place(VALUE self, VALUE x, VALUE y);
8
-
9
3
  VALUE xor_in_place(VALUE self, VALUE x, VALUE y) {
10
- const char *src = 0;
11
- char *dest = 0;
4
+ const char *src;
5
+ char *dest;
12
6
  size_t len;
13
7
  size_t y_len;
14
8
 
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
- }
9
+ Check_Type(x, T_STRING);
10
+ Check_Type(y, T_STRING);
24
11
 
25
12
  rb_str_modify(x);
26
13
  dest = RSTRING_PTR(x);
@@ -41,6 +28,5 @@ VALUE xor_in_place(VALUE self, VALUE x, VALUE y) {
41
28
  }
42
29
 
43
30
  void Init_xorcist() {
44
- Xorcist = rb_define_module("Xorcist");
45
- rb_define_module_function(Xorcist, "xor!", xor_in_place, 2);
31
+ rb_define_module_function(rb_define_module("Xorcist"), "xor!", xor_in_place, 2);
46
32
  }
@@ -3,7 +3,11 @@ require 'xorcist/string_methods'
3
3
  module Xorcist
4
4
  module Refinements
5
5
  refine String do
6
- include Xorcist::StringMethods
6
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.1.0")
7
+ import_methods Xorcist::StringMethods
8
+ else
9
+ include Xorcist::StringMethods
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module Xorcist
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.3'
3
3
  end
data/lib/xorcist.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  require 'xorcist/version'
2
2
 
3
3
  if RUBY_ENGINE == 'jruby'
4
- require 'java'
5
- require File.expand_path('../xorcist.jar', __FILE__)
4
+ require 'jruby'
5
+ require 'xorcist.jar'
6
+ if JRuby.respond_to?(:load_ext)
7
+ JRuby::Util.load_ext('fny.xorcist.XorcistLibrary')
8
+ end
6
9
  else
7
10
  require 'xorcist/xorcist'
8
11
  end
@@ -12,18 +15,4 @@ module Xorcist
12
15
  def xor(x, y)
13
16
  xor!(x.dup, y)
14
17
  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
29
18
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xorcist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Faraz Yashar
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-27 00:00:00.000000000 Z
11
+ date: 2022-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.7.0
33
+ version: '5.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.7.0
40
+ version: '5.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake-compiler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.9.5
61
+ version: 1.1.9
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.9.5
68
+ version: 1.1.9
69
69
  description: Blazing-fast-cross-platform-monkey-patch-free string XOR. Yes, that means
70
70
  JRuby too.
71
71
  email:
@@ -86,7 +86,7 @@ homepage: https://github.com/fny/xorcist
86
86
  licenses:
87
87
  - MIT
88
88
  metadata: {}
89
- post_install_message:
89
+ post_install_message:
90
90
  rdoc_options: []
91
91
  require_paths:
92
92
  - lib
@@ -94,16 +94,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: '0'
97
+ version: 2.0.0
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.6.11
106
- signing_key:
104
+ rubygems_version: 3.3.7
105
+ signing_key:
107
106
  specification_version: 4
108
107
  summary: Blazing-fast-cross-platform-monkey-patch-free string XOR
109
108
  test_files: []