gsm_encoder 0.1.4 → 0.1.5

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/README.md +4 -0
  3. data/lib/gsm_encoder.rb +5 -5
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91c1a1004a76bf14885a1d182f059f9f57164318
4
- data.tar.gz: fa5f8d73b4105406725dcc346794cf02e44097ff
3
+ metadata.gz: 1f714afc19eab777646d3901fd555673bd35f2fc
4
+ data.tar.gz: 34bdd8548d11be5ce085e6a6f933a27eea311b7e
5
5
  SHA512:
6
- metadata.gz: 0d1722f6afc1a458bbc52d9ad7f07b04c84cb4a4be69563bfe8db67563f0c93a41e69aac997fce83b5e47e75c3371f2813667014d5056f96db76adfb9a24e09b
7
- data.tar.gz: 0e0e21460277b77fe888c62ef7ac7a21dab7790cf38398c36f7b891db56da1995a94e16dbcfe09fba5dcd184c828eb253b4e059b266c97823965c4ddd62ffdde
6
+ metadata.gz: aaefbcb9d51481a45945bd9a813d69afa702b69eb5b1133098345e91df692f05d3cfd69215b85d485fd8780e9983c65d31d2ac436a0004e6ab0ad01a3fefe0c9
7
+ data.tar.gz: e54b37b0edb6abf06cd6c725c4bba5bce500b07d9b6cdb878d50fdaca01ead3b3d3884a20f8ed66a31c820569a0fc435afa9b462178660ec1e6ee929500c415f
data/README.md CHANGED
@@ -47,3 +47,7 @@ unsupported strings
47
47
  ### 0.1.4
48
48
 
49
49
  Code cleanup and speedup
50
+
51
+ ### 0.1.5
52
+
53
+ Even faster. About 4 times. Many thanks to @dlarrabee
data/lib/gsm_encoder.rb CHANGED
@@ -55,13 +55,13 @@ module GSMEncoder
55
55
  # @param str The String to verfiy
56
56
  # @return True if the charset can represent every character in the Ruby
57
57
  # String, otherwise false.
58
- def can_encode? str
58
+ def can_encode?(str)
59
59
  return true if !str
60
60
 
61
61
  str.each_char do |c|
62
62
  # simple range checks for most common characters (' '..'_') or ('a'..'~')
63
63
  b = c.getbyte(0)
64
- unless b >= 0x20 && b <= 0x5F || b >= 0x61 && b <= 0x7E || CHARS.index(c)
64
+ unless b >= 0x20 && b <= 0x5F || b >= 0x61 && b <= 0x7E || CHARS.include?(c)
65
65
  return false
66
66
  end
67
67
  end
@@ -77,10 +77,10 @@ module GSMEncoder
77
77
 
78
78
  begin
79
79
  str.each_char do |c|
80
- if index = EXT_CHAR_TABLE.index(c)
81
- buffer << EXTENDED_ESCAPE
80
+ if index = CHAR_TABLE.rindex(c)
82
81
  buffer << index
83
- elsif index = CHAR_TABLE.rindex(c)
82
+ elsif index = EXT_CHAR_TABLE.index(c)
83
+ buffer << EXTENDED_ESCAPE
84
84
  buffer << index
85
85
  else
86
86
  buffer << replace_char
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gsm_encoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Korolev