berns 4.1.0 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.org +10 -8
- data/ext/berns/berns.c +19 -1
- data/lib/berns/berns.bundle +0 -0
- data/lib/berns/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9332f5ed53d3722052cc33ff3796a47555a50586e89512df69ac2f314dec592c
|
4
|
+
data.tar.gz: 381ebd539a72cb79925554928cb11503104beae42b3ec5f4566e973ac4647409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6001d1682311fffcddebb1d6cfefa7d9094386dae315d6d5b2d3a4a36a34ebdb97f9e5721c74b5f7dc4d8bfc1118fbf6c417f7bcc38f79c7158144729fe7909a
|
7
|
+
data.tar.gz: 7fce9c7ca12b3fec44c75902e3724ef6f4d6b11d77855e77864326bb4b1b3d8f53f47b45b99b59b70a37fe6f06199abf79cee317d2f28a0ff7931530f996cf87
|
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
|
219
|
-
|
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
|
-
|
224
|
-
|
225
|
+
ruby 27.521k i/100ms
|
226
|
+
c-ext 74.915k i/100ms
|
225
227
|
Calculating -------------------------------------
|
226
|
-
|
227
|
-
|
228
|
+
ruby 275.913k (± 1.0%) i/s - 1.404M in 5.087516s
|
229
|
+
c-ext 813.113k (± 1.0%) i/s - 4.120M in 5.067902s
|
228
230
|
|
229
231
|
Comparison:
|
230
|
-
|
231
|
-
|
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
|
-
|
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
|
/*
|
@@ -452,6 +465,9 @@ static VALUE external_to_attributes(RB_UNUSED_VAR(VALUE self), VALUE attributes)
|
|
452
465
|
return rstring;
|
453
466
|
}
|
454
467
|
|
468
|
+
/*
|
469
|
+
* Create a void element i.e. one without children/content.
|
470
|
+
*/
|
455
471
|
static char * void_element(const char *tag, size_t tlen, VALUE attributes) {
|
456
472
|
const char *empty = "";
|
457
473
|
char *attrs = hash_value_to_attribute(empty, 0, attributes);
|
@@ -478,6 +494,8 @@ static char * void_element(const char *tag, size_t tlen, VALUE attributes) {
|
|
478
494
|
|
479
495
|
ptr = stecpy(ptr, tag_close, end);
|
480
496
|
|
497
|
+
free(attrs);
|
498
|
+
|
481
499
|
return dest;
|
482
500
|
}
|
483
501
|
|
data/lib/berns/berns.bundle
CHANGED
Binary file
|
data/lib/berns/version.rb
CHANGED
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.
|
4
|
+
version: 4.1.2
|
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-
|
12
|
+
date: 2022-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A utility library for generating HTML strings.
|
15
15
|
email:
|