fast_xor 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +2 -2
- data/ext/xor/xor.c +64 -64
- data/lib/.gemkeep +0 -0
- metadata +30 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b1c941175d77900970a3bbc568be260c896f412
|
4
|
+
data.tar.gz: cf805ef311aff282e0147cc73e5b71403d546953
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1259e0b0a781dd6bb62265774ccfd36a74712e6b9bf5106d3d988a27fa9cc191bedf63b4c3ab3cd504abb7760154f81a01ff6569d2ff34f0b69c96663e3361f6
|
7
|
+
data.tar.gz: 06e8af5936c679092e37c20d42ebe3d96cfb44697f127d0592b63525c7b6e7a819b1276a8f5d55ee477a9c5e3ab317ce9ae278537f6579847adefbecd0cc5d10
|
data/README.rdoc
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
== How fast is "Fast"?
|
20
20
|
|
21
|
-
Almost
|
21
|
+
Almost 50x faster than pure Ruby, on my machine (your mileage my vary):
|
22
22
|
|
23
23
|
$ ./benchmark
|
24
24
|
user system total real
|
@@ -28,6 +28,6 @@ Almost 50,000x faster than pure Ruby, on my machine (your mileage my vary):
|
|
28
28
|
|
29
29
|
Author:: Steve Sloan (mailto:steve@finagle.org)
|
30
30
|
Website:: http://github.com/CodeMonkeySteve/fast_xor
|
31
|
-
Copyright:: Copyright (c) 2009-
|
31
|
+
Copyright:: Copyright (c) 2009-2013 Steve Sloan
|
32
32
|
License:: MIT
|
33
33
|
|
data/ext/xor/xor.c
CHANGED
@@ -1,64 +1,64 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <ruby.h>
|
3
|
-
|
4
|
-
/* Backward compatibility with Ruby 1.8 */
|
5
|
-
#ifndef RSTRING_PTR
|
6
|
-
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
7
|
-
#endif
|
8
|
-
#ifndef RSTRING_LEN
|
9
|
-
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
10
|
-
#endif
|
11
|
-
|
12
|
-
VALUE string_xor( int argc, VALUE *argv, VALUE self ) {
|
13
|
-
const char *src = 0;
|
14
|
-
char *
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
if ( TYPE(argv[1]) == T_STRING ) {
|
44
|
-
|
45
|
-
|
46
|
-
if ( l < length )
|
47
|
-
length = l;
|
48
|
-
} else {
|
49
|
-
rb_raise( rb_eTypeError, "in method '" "xor" "', argument " "2"" of type '" "String""'" );
|
50
|
-
return Qnil;
|
51
|
-
}
|
52
|
-
|
53
|
-
for ( ; length--; ++dest, ++src, ++src2 )
|
54
|
-
*dest ^= *src ^ *src2;
|
55
|
-
}
|
56
|
-
|
57
|
-
return self;
|
58
|
-
}
|
59
|
-
|
60
|
-
|
61
|
-
void Init_xor( void )
|
62
|
-
{
|
63
|
-
rb_define_method( rb_cString, "xor!", ((VALUE (*)(ANYARGS)) string_xor), -1 );
|
64
|
-
}
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
/* Backward compatibility with Ruby 1.8 */
|
5
|
+
#ifndef RSTRING_PTR
|
6
|
+
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
7
|
+
#endif
|
8
|
+
#ifndef RSTRING_LEN
|
9
|
+
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
10
|
+
#endif
|
11
|
+
|
12
|
+
VALUE string_xor( int argc, VALUE *argv, VALUE self ) {
|
13
|
+
const char *src = 0;
|
14
|
+
const char *src2 = 0;
|
15
|
+
char *dest = 0 ;
|
16
|
+
size_t length = 0;
|
17
|
+
size_t l;
|
18
|
+
|
19
|
+
if ( (argc < 1) || (argc > 2) ) {
|
20
|
+
rb_raise( rb_eArgError, "wrong # of arguments(%d for 1 or 2)", argc );
|
21
|
+
return Qnil;
|
22
|
+
}
|
23
|
+
|
24
|
+
rb_str_modify(self);
|
25
|
+
dest = RSTRING_PTR(self);
|
26
|
+
length = RSTRING_LEN(self);
|
27
|
+
|
28
|
+
if ( TYPE(argv[0]) == T_STRING ) {
|
29
|
+
l = RSTRING_LEN(argv[0]);
|
30
|
+
src = RSTRING_PTR(argv[0]);
|
31
|
+
if ( l < length )
|
32
|
+
length = l;
|
33
|
+
} else {
|
34
|
+
rb_raise( rb_eTypeError, "in method '" "xor" "', argument " "1"" of type '" "String""'" );
|
35
|
+
return Qnil;
|
36
|
+
}
|
37
|
+
|
38
|
+
if ( argc == 1 ) {
|
39
|
+
for ( ; length--; ++dest, ++src )
|
40
|
+
*dest ^= *src;
|
41
|
+
|
42
|
+
} else {
|
43
|
+
if ( TYPE(argv[1]) == T_STRING ) {
|
44
|
+
l = RSTRING_LEN(argv[1]);
|
45
|
+
src2 = RSTRING_PTR(argv[1]);
|
46
|
+
if ( l < length )
|
47
|
+
length = l;
|
48
|
+
} else {
|
49
|
+
rb_raise( rb_eTypeError, "in method '" "xor" "', argument " "2"" of type '" "String""'" );
|
50
|
+
return Qnil;
|
51
|
+
}
|
52
|
+
|
53
|
+
for ( ; length--; ++dest, ++src, ++src2 )
|
54
|
+
*dest ^= *src ^ *src2;
|
55
|
+
}
|
56
|
+
|
57
|
+
return self;
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
void Init_xor( void )
|
62
|
+
{
|
63
|
+
rb_define_method( rb_cString, "xor!", ((VALUE (*)(ANYARGS)) string_xor), -1 );
|
64
|
+
}
|
data/lib/.gemkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,49 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_xor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Steve Sloan
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rake-compiler
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rspec
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
description: Provides a C-optimized method for in-place XORing of two (or three) strings
|
48
56
|
email: steve@finagle.org
|
49
57
|
executables: []
|
@@ -55,39 +63,33 @@ files:
|
|
55
63
|
- MIT-LICENSE
|
56
64
|
- README.rdoc
|
57
65
|
- benchmark
|
66
|
+
- lib/.gemkeep
|
58
67
|
- ext/xor/xor.c
|
59
68
|
- ext/xor/extconf.rb
|
60
69
|
- spec/xor_spec.rb
|
61
70
|
homepage: http://github.com/CodeMonkeySteve/fast_xor
|
62
71
|
licenses: []
|
72
|
+
metadata: {}
|
63
73
|
post_install_message:
|
64
74
|
rdoc_options:
|
65
75
|
- --charset=UTF-8
|
66
76
|
require_paths:
|
67
|
-
- lib
|
77
|
+
- lib
|
68
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
79
|
requirements:
|
71
|
-
- -
|
80
|
+
- - '>='
|
72
81
|
- !ruby/object:Gem::Version
|
73
82
|
version: '0'
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
hash: -1801665792831442865
|
77
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
84
|
requirements:
|
80
|
-
- -
|
85
|
+
- - '>='
|
81
86
|
- !ruby/object:Gem::Version
|
82
87
|
version: '0'
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
hash: -1801665792831442865
|
86
88
|
requirements: []
|
87
89
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.
|
90
|
+
rubygems_version: 2.1.11
|
89
91
|
signing_key:
|
90
|
-
specification_version:
|
92
|
+
specification_version: 4
|
91
93
|
summary: Fast String XOR operator
|
92
94
|
test_files:
|
93
95
|
- spec/xor_spec.rb
|