fast-polylines 2.1.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: ef058eadb11fa085c5298a026a53a28cb11fd2e2320471af3999560102fdf918
4
- data.tar.gz: 361297656bbc9785ab69c977574be178cf37206dd9c11897a0084f544f75242e
3
+ metadata.gz: 0ab14d087b6992d7abec3047ad38aea4e7474f4bfff06b921ea91699bd788172
4
+ data.tar.gz: 4225fc53ff0801e6b145058461d9cf6d5f65be902787a7496e85c83883b52ba5
5
5
  SHA512:
6
- metadata.gz: b68fddf33a97de12330bcc41c69d9d3d96061b65fafee34cfe5bad5d5af6abc106608d68b28961ce0905b7c8d252da19acef389872263c6a9aa99e539b9d18fc
7
- data.tar.gz: 3ee95983cf98fe415340a7f9c9ade2c9b9a33584addf481d64752fd48d2b587179e373bac7550507e332e0df075fdd1a3015bac44ff249244ad760f8577e40b2
6
+ metadata.gz: 82f43939d565a422fdf0696539f1c668d851aa88ff36d52a9f3ad2d909ebfe095c1ccd0b7266243943c834f70dc5c954c85715a3c435768df2c6ccce871443b4
7
+ data.tar.gz: 97ab65e7683ecbb53bf5673532e5ff99399b7f0b97b140221127b302e2d54020c1e3b1b6c174a624c49d276801b0f76089e3378cf5949b7a8fdad64494d89db0
@@ -5,17 +5,30 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
6
6
  This project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
-
9
8
  ## [unreleased] —
10
9
 
11
10
  ### Added
12
11
 
13
- - A Require ptah that match the gem name (#18)
12
+ ### Changed
13
+
14
+ ### Fixed
15
+
16
+ ## [2.2.0] — 2020-11-24
17
+
18
+ ### Added
19
+
20
+ - support for windows (#19 #23) by [@mohits]
14
21
 
15
22
  ### Changed
16
23
 
24
+ - Speedup calculation by avoiding calling pow(10,x) (#22) by [@mohits]
25
+
17
26
  ### Fixed
18
27
 
28
+ - move from travis to github actions
29
+
30
+ [@mohits]: https://github.com/mohits
31
+
19
32
  ## [2.1.0] — 2020-04-30
20
33
 
21
34
  ### Added
@@ -29,6 +42,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
29
42
  - Broken behavior when approaching the chunk size limit (#16)
30
43
 
31
44
 
32
- [unreleased]: https://github.com/klaxit/fast-polylines/compare/v2.1.0...HEAD
45
+ [unreleased]: https://github.com/klaxit/fast-polylines/compare/v2.2.0...HEAD
46
+ [2.2.0]: https://github.com/klaxit/fast-polylines/compare/v2.1.0...v2.2.0
33
47
  [2.1.0]: https://github.com/klaxit/fast-polylines/compare/v2.0.1...v2.1.0
34
48
  [2.0.1]: https://github.com/klaxit/fast-polylines/compare/v2.0.0...v2.0.1
@@ -24,6 +24,21 @@
24
24
  #define rdbg(...)
25
25
  #endif
26
26
 
27
+ typedef unsigned int uint;
28
+
29
+ // Speed up the code a bit by not calling pow(10.0, precision) since it is
30
+ // always 10^precision. Convert that into a lookup instead of doing the
31
+ // calculation.
32
+ // The precision parameter is already checked in +_get_precision()+ to ensure
33
+ // that it is within the range.
34
+ static inline double _fast_pow10(uint precision) {
35
+ const double lookup[MAX_PRECISION + 1] = {
36
+ 1.0, 10.0, 1.0e+2, 1.0e+3, 1.0e+4, 1.0e+5, 1.0e+6, 1.0e+7,
37
+ 1.0e+8, 1.0e+9, 1.0e+10, 1.0e+11, 1.0e+12, 1.0e+13
38
+ };
39
+ return lookup[precision];
40
+ }
41
+
27
42
  static inline uint _get_precision(VALUE value) {
28
43
  int precision = NIL_P(value) ? DEFAULT_PRECISION : NUM2INT(value);
29
44
  if (precision > MAX_PRECISION) rb_raise(rb_eArgError, "precision too high (https://xkcd.com/2170/)");
@@ -37,7 +52,8 @@ rb_FastPolylines__decode(int argc, VALUE *argv, VALUE self) {
37
52
  Check_Type(argv[0], T_STRING);
38
53
  char* polyline = StringValueCStr(argv[0]);
39
54
  uint precision = _get_precision(argc > 1 ? argv[1] : Qnil);
40
- double precision_value = pow(10.0, precision);
55
+ double precision_value = _fast_pow10(precision);
56
+
41
57
  VALUE ary = rb_ary_new();
42
58
  // Helps keeping track of whether we are computing lat (0) or lng (1).
43
59
  uint8_t index = 0;
@@ -98,7 +114,8 @@ rb_FastPolylines__encode(int argc, VALUE *argv, VALUE self) {
98
114
  uint precision = _get_precision(argc > 1 ? argv[1] : Qnil);
99
115
  dbg("rb_FastPolylines__encode(..., %u)\n", precision);
100
116
  rdbg(argv[0]);
101
- double precision_value = pow(10.0, precision);
117
+ double precision_value = _fast_pow10(precision);
118
+
102
119
  // This is the maximum possible size the polyline may have. This
103
120
  // being **without** null character. To copy it later as a Ruby
104
121
  // string we'll have to use `rb_str_new` with the length.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FastPolylines
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast-polylines
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrille Courtière
8
8
  - Ulysse Buonomo
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-30 00:00:00.000000000 Z
12
+ date: 2020-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: benchmark-ips
@@ -53,7 +53,7 @@ dependencies:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.5'
56
- description:
56
+ description:
57
57
  email:
58
58
  - dev@klaxit.com
59
59
  executables: []
@@ -76,7 +76,7 @@ homepage: https://github.com/klaxit/fast-polylines
76
76
  licenses:
77
77
  - MIT
78
78
  metadata: {}
79
- post_install_message:
79
+ post_install_message:
80
80
  rdoc_options: []
81
81
  require_paths:
82
82
  - lib
@@ -91,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.1.0.pre3
95
- signing_key:
94
+ rubygems_version: 3.1.2
95
+ signing_key:
96
96
  specification_version: 4
97
97
  summary: Fast & easy Google polylines
98
98
  test_files: