hashids 1.0.4 → 1.0.5

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.
Files changed (5) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +6 -5
  3. data/README.md +6 -1
  4. data/lib/hashids.rb +10 -9
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bcf921c95958fac763731852a7bada447d74e30f
4
- data.tar.gz: 6f6c71145d00140152c127e0978c28966fc30fe1
2
+ SHA256:
3
+ metadata.gz: bd2447b35dec96410f58a8c4e09c8ca71b1d82be3085c31a47ff15925ba25c48
4
+ data.tar.gz: 19bc31151f60ecb16d435d27c5dd729d5916105b78e428e20abf03a721d243d7
5
5
  SHA512:
6
- metadata.gz: 6170e1679f92a5590f4a64c9350dd64bbca1518725726ef0340bd375c6c5f71779bf80b7dfd043e78b3c70ee00075376fcab13e57645ef36e45ec48efb9da154
7
- data.tar.gz: b3baeb0247049a60da810b66206f44018923b248cf511451239053a0ec8f1c35d39e9ff0e71f5eb6c57ea0d6cd1ff1bccbab6e3806d0bbe9c9b2e2c2f720d602
6
+ metadata.gz: f65cde7092f2495f0cbcbdd91e49b694eadccbb28c8ef544cf118ce3ac152bc87cd6cfc7544aaf82b24cef59fb6ae4ea2bd87fb66a001107ab46ed0b751e58f1
7
+ data.tar.gz: 617de24d05f872da30cfb701327e4cf45bb8cee856190e648df5e156bf753697c88c1ce53c23dabc1be60d0eaaeadc98a8b82c5319836d637bf367a64fbbb9e9
@@ -3,12 +3,13 @@ language: ruby
3
3
  bundler_args: --without documentation
4
4
 
5
5
  rvm:
6
- - 2.4.0
7
- - 2.3.3
8
- - 2.2.6
6
+ - 2.5.1
7
+ - 2.4.5
8
+ - 2.3.8
9
+ - 2.2.10
9
10
  - 2.1.10
10
11
  - 2.0.0
11
- - jruby-9.1.6.0
12
- - jruby-1.7.26
12
+ - jruby-9.1.17.0
13
+ - jruby-1.7.27
13
14
 
14
15
  sudo: false
data/README.md CHANGED
@@ -6,7 +6,7 @@ Use hashids when you do not want to expose your database ids to the user.
6
6
  [http://hashids.org/ruby/](http://hashids.org/ruby/)
7
7
 
8
8
  [![Build Status](https://travis-ci.org/peterhellberg/hashids.rb.svg?branch=master)](http://travis-ci.org/peterhellberg/hashids.rb)
9
- (2.4.0 2.3.1, 2.2.5, 2.1.9, 2.0.0, jruby-9.0.5.0, jruby-1.7.20)
9
+ (2.5.1, 2.4.5, 2.3.8, 2.2.10, 2.1.10, 2.0.0, jruby-9.1.17.0, jruby-1.7.27)
10
10
 
11
11
  ## What is it?
12
12
 
@@ -208,6 +208,11 @@ hex_str = hashids.decode_hex("kRNrpKlJ")
208
208
 
209
209
  ## Changelog
210
210
 
211
+ **1.0.5**
212
+
213
+ - Improve shuffle performance
214
+ - Update rubies used by Travis-CI
215
+
211
216
  **1.0.4**
212
217
 
213
218
  - Improved encode/decode performance
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class Hashids
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.5"
5
5
 
6
6
  MIN_ALPHABET_LENGTH = 16
7
7
  SEP_DIV = 3.5
@@ -142,18 +142,19 @@ class Hashids
142
142
 
143
143
  def consistent_shuffle(alphabet, salt)
144
144
  return alphabet if salt.nil? || salt.empty?
145
- v = 0
146
- p = 0
147
- chars = alphabet.chars.to_a
148
- slen = salt.length
145
+
146
+ chars = alphabet.each_char.to_a
147
+ salt_ords = salt.codepoints.to_a
148
+ salt_length = salt_ords.length
149
+ idx = ord_total = 0
150
+
149
151
  (alphabet.length-1).downto(1) do |i|
150
- v = v % slen
151
- p += n = salt[v].ord
152
- j = (n + v + p) % i
152
+ ord_total += n = salt_ords[idx]
153
+ j = (n + idx + ord_total) % i
153
154
 
154
155
  chars[i], chars[j] = chars[j], chars[i]
155
156
 
156
- v += 1
157
+ idx = (idx + 1) % salt_length
157
158
  end
158
159
 
159
160
  chars.join
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashids
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Hellberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2018-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use hashids when you do not want to expose your database ids to the user.
14
14
  email:
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project:
48
- rubygems_version: 2.6.8
48
+ rubygems_version: 2.7.7
49
49
  signing_key:
50
50
  specification_version: 4
51
51
  summary: Generate YouTube-like hashes from one or many numbers.