z85 0.10 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ext/z85/z85.c +20 -20
  3. data/lib/z85/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b160adbdea010f5e0545cd033922819550b2b8f435422ff3ba363000345e2ca
4
- data.tar.gz: 1703dd4ddbf8c142be0b6c22fa658814ecbd413127c39fc09e2f6ca75d2fc050
3
+ metadata.gz: e7e357196aefb2cecd96eacf44ca120034fa9082210055dd7db46fa1b1b05e3e
4
+ data.tar.gz: 7ef29017f657680b64138a1d163774a12f78cbb7202e324c4eefefbf947ee81d
5
5
  SHA512:
6
- metadata.gz: '0894598b2ce5a09fba76ec6122c2bd57571b73f03947a979b3450595e741875083cbbfebeb3413b5713c07dd65648228c2e4356b501e661a99048e422ce94a5d'
7
- data.tar.gz: 4a0d167f327f6c2409a04a0d2cc680da05fece160eeba3d126639e725413c764469c01b032eec9b693a9b3c239b2751f983671d135db4e447142d5e6b4d87c10
6
+ metadata.gz: c57c7471bf3e66bee9e6987c280e7355c41ecf213f4e10792790b5a16a0ca27d0e6a6b2621663f767435910c7364faad2f628b0c8de2321a3938dd6549d929bf
7
+ data.tar.gz: 26714969d363d9f5b4f81d6c4f4754a283b1d4028ed4bfa9dcc5231fe63d95e5d6b1bdd7c4e4de43d1db5a306d6cdbe818a18062c25aa0db30ae36c10f2247bd
@@ -71,18 +71,18 @@ static VALUE z85_encode(VALUE _mod, VALUE string)
71
71
  char* encoded = xmalloc(encoded_len + 1);
72
72
  uint char_nbr = 0;
73
73
  uint byte_nbr = 0;
74
- uint32_t value = 0;
75
74
 
76
75
  while (byte_nbr < size) {
77
- value = value * 256 + data[byte_nbr++];
78
- if (byte_nbr % 4 == 0) {
79
- uint divisor = 85 * 85 * 85 * 85;
80
- while (divisor) {
81
- encoded[char_nbr++] = encoder[value / divisor % 85];
82
- divisor /= 85;
83
- }
84
- value = 0;
85
- }
76
+ uint32_t value = 0;
77
+
78
+ for (int i = 0; i < 4; i++)
79
+ value = value*256 + data[byte_nbr++];
80
+
81
+ encoded[char_nbr++] = encoder[value/(85*85*85*85) % 85];
82
+ encoded[char_nbr++] = encoder[value/(85*85*85) % 85];
83
+ encoded[char_nbr++] = encoder[value/(85*85) % 85];
84
+ encoded[char_nbr++] = encoder[value/85 % 85];
85
+ encoded[char_nbr++] = encoder[value % 85];
86
86
  }
87
87
  encoded[char_nbr] = 0;
88
88
 
@@ -103,17 +103,17 @@ static VALUE z85_decode(VALUE _mod, VALUE rstring)
103
103
 
104
104
  uint byte_nbr = 0;
105
105
  uint char_nbr = 0;
106
- uint32_t value = 0;
106
+
107
107
  while (char_nbr < strlen) {
108
- value = value * 85 + decoder[(byte) string[char_nbr++] - 32];
109
- if (char_nbr % 5 == 0) {
110
- uint divisor = 256 * 256 * 256;
111
- while (divisor) {
112
- decoded[byte_nbr++] = value / divisor % 256;
113
- divisor /= 256;
114
- }
115
- value = 0;
116
- }
108
+ uint32_t value = 0;
109
+
110
+ for (int i = 0; i < 5; i++)
111
+ value = value*85 + decoder[(byte) string[char_nbr++] - 32];
112
+
113
+ decoded[byte_nbr++] = value/(256*256*256) % 256;
114
+ decoded[byte_nbr++] = value/(256*256) % 256;
115
+ decoded[byte_nbr++] = value/256 % 256;
116
+ decoded[byte_nbr++] = value % 256;
117
117
  }
118
118
 
119
119
  VALUE out = rb_str_new((const char*) decoded, decoded_size);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Z85
4
- VERSION = "0.10"
4
+ VERSION = "0.11"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: z85
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.10'
4
+ version: '0.11'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Noria