berns 4.1.0 → 4.1.1

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: eb2de0ba05a5e234fa5cef7edf3a222411222d0743c0e69492c1e1d5e53541bb
4
- data.tar.gz: f62f2273f787a46aa18784b668f1110adb80a1bbb8c33226c9c58e585d5acec7
3
+ metadata.gz: c6e746c49f8701090aa423558ef9ccc644cff448b9c9c4f0c55e2752fda3ccf6
4
+ data.tar.gz: 9cb5b7761c29041c95b0ae9e00b4d98f8bffc06130bd02f9d3e4cecec31bc310
5
5
  SHA512:
6
- metadata.gz: 7d8fb46aeb4dc948729b36bbb6a794625618c34742ee2b18024d1cde99bda330b21bd7fb890bd241010a9b60e956c81fe401c3036464a90d28fb4ebca11ba621
7
- data.tar.gz: c7c430ae90da5be3b93f15d1ac6ab2bba300b89558cfb131af276b2af9d2e82b118fa0691000402bf7e982e13406defc275c786e2e512304041f660afe0b53cc
6
+ metadata.gz: 465a227cbce7038041f4faf90a976fdd2d04a0833f140acf9c3aa26f74d6a9439155aa4bf15fbd78801aefc3b5fa88f7de11b248817e7e3ce83efc5983d9330e
7
+ data.tar.gz: e33fb6252cd1ab022d7543fb0275d2e1dc3e13fd1c966bb53ca3b806029d3b498212137995597910f6382bc036d4e22c322892732ca8a65ab49bc37b917451c7
data/README.org CHANGED
@@ -215,20 +215,22 @@ area base br col embed hr img input link menuitem meta param source track wbr
215
215
 
216
216
  ** Performance
217
217
 
218
- Berns 3 is about three times faster than the pure Ruby implementation used in
219
- version 2. See the file [[file:benchmarks/performance.rb][benchmarks/performance.rb]] for the benchmark code.
218
+ Berns 3 was a total rewrite from a pure Ruby implementation to one powered by a
219
+ C extension. That rewrite is about three times faster than the pure Ruby
220
+ implementation used in version 2. See the file [[file:benchmarks/performance.rb][benchmarks/performance.rb]] for the
221
+ benchmark code.
220
222
 
221
223
  #+begin_example
222
224
  Warming up --------------------------------------
223
- element 27.373k i/100ms
224
- berns 94.118k i/100ms
225
+ ruby 27.521k i/100ms
226
+ c-ext 74.915k i/100ms
225
227
  Calculating -------------------------------------
226
- element 314.078k4.5%) i/s - 1.588M in 5.065539s
227
- berns 935.528k6.1%) i/s - 4.706M in 5.049718s
228
+ ruby 275.913k1.0%) i/s - 1.404M in 5.087516s
229
+ c-ext 813.113k1.0%) i/s - 4.120M in 5.067902s
228
230
 
229
231
  Comparison:
230
- berns: 935527.9 i/s
231
- element: 314078.4 i/s - 2.98x (± 0.00) slower
232
+ c-ext: 813113.3 i/s
233
+ ruby: 275913.5 i/s - 2.95x (± 0.00) slower
232
234
  #+end_example
233
235
 
234
236
  ** Trivia
data/ext/berns/berns.c CHANGED
@@ -357,7 +357,20 @@ static char * hash_value_to_attribute(const char *attr, const size_t attrlen, VA
357
357
  free(combined);
358
358
  }
359
359
 
360
- return destination;
360
+ /*
361
+ * Reallocate destination to final size. This is generally a reduction in the
362
+ * allocated memory since we chunk allocations in 256 byte multiples.
363
+ */
364
+ char *rightsizeddest = realloc(destination, occupied + 1);
365
+
366
+ if (rightsizeddest == NULL) {
367
+ free(destination);
368
+ rb_raise(rb_eNoMemError, "Berns could not allocate sufficient memory.");
369
+ }
370
+
371
+ rightsizeddest[occupied] = '\0';
372
+
373
+ return rightsizeddest;
361
374
  }
362
375
 
363
376
  /*
Binary file
data/lib/berns/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Berns
3
- VERSION = '4.1.0'
3
+ VERSION = '4.1.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berns
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Beck
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-14 00:00:00.000000000 Z
12
+ date: 2022-09-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A utility library for generating HTML strings.
15
15
  email: