mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Make static atom pointers constexpr
.
This saves one word per static atom, per process. The `nsGkAtoms` change is only a small part of this commit. In regen_atoms.py: - There is now only one link name per platform: nsGkAtoms::sAtoms[]. - But there is a new constant per atom, giving the index into nsGkAtoms::sAtoms[]. - And the `atom!` macro for each atom indexes into nsGkAtoms::sAtoms[] using the index constant. - A couple of `*mut` pointers are now `*const`. Elsewhere, the `(nsStaticAtom*)` casts within the `AppendElement()` calls are necessary to avoid link errors, presumably due to some template instantiation wrinkle. Bug: 1449787 Reviewed-by: froydnj,emilio
This commit is contained in:
parent
c276c8a341
commit
0d5d5a9c82
2 changed files with 30 additions and 46 deletions
|
@ -4,6 +4,10 @@
|
|||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
// This is needed for the constants in atom_macro.rs, because we have some
|
||||
// atoms whose names differ only by case, e.g. datetime and dateTime.
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
//! A drop-in replacement for string_cache, but backed by Gecko `nsAtom`s.
|
||||
|
||||
use gecko_bindings::bindings::Gecko_AddRefAtom;
|
||||
|
@ -280,7 +284,7 @@ impl Atom {
|
|||
/// that way, now we have sugar for is_static, creating atoms using
|
||||
/// Atom::from_raw should involve almost no overhead.
|
||||
#[inline]
|
||||
pub unsafe fn from_static(ptr: *mut nsStaticAtom) -> Self {
|
||||
pub unsafe fn from_static(ptr: *const nsStaticAtom) -> Self {
|
||||
let atom = Atom(ptr as *mut WeakAtom);
|
||||
debug_assert!(
|
||||
atom.is_static(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue