Skip to content

Commit

Permalink
perf(html5): use a hashmap to detect duplicate attributes
Browse files Browse the repository at this point in the history
If there are more than 16 attributes, shift from doing strcmp to using
a hashmap for duplicate detection. The number 16 was chosen based on
the benchmark in #2568

I've introduced @tidwall's hashmap.c (MIT licensed and the copyright
appropriately copied in the LICENSE-DEPENDENCIES file) to have
something self-contained within the libgumbo codebase, rather than
using libxml2's xmlHash or ruby's st.c.
  • Loading branch information
flavorjones committed Dec 27, 2024
1 parent 2611599 commit 41c601d
Show file tree
Hide file tree
Showing 10 changed files with 1,416 additions and 20 deletions.
29 changes: 29 additions & 0 deletions LICENSE-DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Note that this document is broken into multiple sections, each of which describe
* [Native WindowsⓇ platform releases ("x64-mingw-ucrt")](#native-windows%E2%93%A1-platform-releases-x64-mingw-ucrt)
* [JavaⓇ (JRuby) platform release ("java")](#java%E2%93%A1-jruby-platform-release-java)
- [Appendix: Dependencies' License Texts](#appendix-dependencies-license-texts)
* [hashmap.c](#hashmapc)
* [libgumbo](#libgumbo)
* [libxml2](#libxml2)
* [libxslt](#libxslt)
Expand Down Expand Up @@ -112,6 +113,34 @@ This section contains a subsection for each potentially-distributed dependency,
Please see previous sections to understand which of these potential dependencies is actually distributed in the gem file you're downloading and using.


### hashmap.c

MIT

https://github.com/tidwall/hashmap.c/blob/master/LICENSE

The MIT License (MIT)

Copyright (c) 2020 Joshua J Baker

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


### libgumbo

Apache 2.0
Expand Down
2 changes: 2 additions & 0 deletions gumbo-parser/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ gumbo_objs := \
char_ref.o \
error.o \
foreign_attrs.o \
hashmap.o \
parser.o \
string_buffer.o \
string_piece.o \
string_set.o \
svg_attrs.o \
svg_tags.o \
tag.o \
Expand Down
Loading

0 comments on commit 41c601d

Please sign in to comment.