Skip to content

Add an Atom::try_static method#238

Merged
bors-servo merged 1 commit into
servo:masterfrom
leops:try_static
Apr 20, 2021
Merged

Add an Atom::try_static method#238
bors-servo merged 1 commit into
servo:masterfrom
leops:try_static

Conversation

@leops
Copy link
Copy Markdown
Contributor

@leops leops commented Apr 20, 2021

This methods returns a new static Atom, or None if the provided string is not present in the static table. This is an optimization when using this library to speed up matching against a large table of static atoms, as it allows to skip locking the global table and inserting the new string when the match is going to fail anyway.

I'm not too sure about the name of the method but nothing better comes to mind right now, and same goes for the specifics of the implementation (I moved the hash calculation to a private method to limit code duplication but it's only three lines so it's probably not that important, plus returning the Hashes in Result::Err seems dubious)

@jdm
Copy link
Copy Markdown
Member

jdm commented Apr 20, 2021

@bors-servo r+
This looks reasonable to me. Thanks!

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit c057dde has been approved by jdm

@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit c057dde with merge 0cf93bb...

@bors-servo
Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-travis
Approved by: jdm
Pushing 0cf93bb to master...

@bors-servo bors-servo merged commit 0cf93bb into servo:master Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants