Skip to content

Commit 3a18e14

Browse files
author
bors-servo
authored
Auto merge of #175 - aidanhs:aphs-faster-cmp, r=SimonSapin
Make cmp massively faster for inline atoms This is a big deal if you're putting atoms inside a btreeset since it does a lot of cmp operations. It's more unsafe, but 1. the only thing that constructs `Inline` atoms should be the `string-cache` code (which I've been utilising fairly heavily) 2. if `string-cache` code *isn't* the only thing constructing atoms, `Dynamic` atoms are wildly unsafe since they contain pointers 3. since the creation of `Inline` atoms is only dependent on length of string (not content) you can exhaustively check correctness just by inlining and derefing strings from `"a"` to `"aaaaaaa"`. I can add an explicit test for this if you like. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/string-cache/175) <!-- Reviewable:end -->
2 parents c60c4f5 + c322938 commit 3a18e14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/atom/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl ops::Deref for Atom {
322322
match self.unpack() {
323323
Inline(..) => {
324324
let buf = inline_orig_bytes(&self.unsafe_data);
325-
str::from_utf8(buf).unwrap()
325+
str::from_utf8_unchecked(buf)
326326
},
327327
Static(idx) => STATIC_ATOM_SET.index(idx).expect("bad static atom"),
328328
Dynamic(entry) => {

0 commit comments

Comments
 (0)