unicode-display_width 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39825a3fe5306451922de8c4bffb8644fe5c1a7f
4
- data.tar.gz: 734fd44fbda2f64ee75d935f51ef5bdad1ce0aa0
3
+ metadata.gz: 6e98df13369d5af8117d07c174c4c8b50804e083
4
+ data.tar.gz: b4d058625eaeb72fa7c3ac21e1c57b645133ee5a
5
5
  SHA512:
6
- metadata.gz: 170604ecddb364405fd275e84f2230a2d861e3e39b8fcf38a7a2a4baae6a7f79559d4a52505152ac34152a65ee1284ce35d5f5e6db60805fac7e013af71773cb
7
- data.tar.gz: b7248ef38dc57d367767e408f09890e0b5416238f602fe6cc3ed3f90dd7d84e3ab5386d258c7894a5605f15d626c7ef84de11a84575bbaed657d474331973613
6
+ metadata.gz: 4788d4fd57d12278fc92dc73f011a47f1572ac38b5e933d0bb03535a44e988a27e0dc37f265c968a9a0010d59e8e8f29a063eeb19bed1f935e4c7781f476be12
7
+ data.tar.gz: fc663563f837ef8802b4967a044269c2585f99eed98fc0da8a0570427b93f671c6e37932b4ead6bbeeb91b2302dd5b76a0d9fb87c0f5bd5ae76bf59ef20bccfe
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.2
4
+
5
+ - Reduce memory consumption and increase performance, patch by @rrosenblum
6
+
3
7
  ## 1.1.1
4
8
 
5
9
  * Always load index into memory, fixes #9
@@ -3,11 +3,13 @@ require_relative 'display_width/index'
3
3
 
4
4
  module Unicode
5
5
  module DisplayWidth
6
+ DEPTHS = [0x10000, 0x1000, 0x100, 0x10].freeze
7
+
6
8
  def self.of(string, ambiguous = 1, overwrite = {})
7
- res = string.unpack('U*').inject(0){ |total_width, codepoint|
9
+ res = string.unpack('U*'.freeze).inject(0){ |total_width, codepoint|
8
10
  index_or_value = INDEX
9
11
  codepoint_depth_offset = codepoint
10
- [0x10000, 0x1000, 0x100, 0x10].each{ |depth|
12
+ DEPTHS.each{ |depth|
11
13
  index_or_value = index_or_value[codepoint_depth_offset / depth]
12
14
  codepoint_depth_offset = codepoint_depth_offset % depth
13
15
  break unless index_or_value.is_a? Array
@@ -1,6 +1,6 @@
1
1
  module Unicode
2
2
  module DisplayWidth
3
- VERSION = '1.1.1'
3
+ VERSION = '1.1.2'
4
4
  UNICODE_VERSION = "9.0.0".freeze
5
5
  DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + '/../../../data/').freeze
6
6
  INDEX_FILENAME = (DATA_DIRECTORY + '/display_width.marshal.gz').freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicode-display_width
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec