aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/macros.rs
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2013-12-17 14:40:23 -0400
committerBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2013-12-17 16:32:43 -0400
commitcfb73ed1239f14c7c895de9db44ef9a8814e72c0 (patch)
tree9ac3ba7409ffde34d794863c6cc82b7039822d94 /src/components/script/macros.rs
parent0e14745762bb29a050bfc07c507d57a0f3acda1e (diff)
downloadservo-cfb73ed1239f14c7c895de9db44ef9a8814e72c0.tar.gz
servo-cfb73ed1239f14c7c895de9db44ef9a8814e72c0.zip
Make Node::is_in_doc O(1)
Added a flags variable inside Node to represent boolean flags, with is_in_doc being the first of them. It is updated whenever a node is appended or removed from a parent. This patch is for: https://github.com/mozilla/servo/issues/1030
Diffstat (limited to 'src/components/script/macros.rs')
-rw-r--r--src/components/script/macros.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/script/macros.rs b/src/components/script/macros.rs
new file mode 100644
index 00000000000..f8eaa07cc05
--- /dev/null
+++ b/src/components/script/macros.rs
@@ -0,0 +1,22 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#[macro_escape];
+
+macro_rules! bitfield(
+ ($bitfieldname:ident, $getter:ident, $setter:ident, $value:expr) => (
+ impl $bitfieldname {
+ #[inline]
+ pub fn $getter(self) -> bool {
+ (*self & $value) != 0
+ }
+
+ #[inline]
+ pub fn $setter(&mut self, value: bool) {
+ *self = $bitfieldname((**self & !$value) | (if value { $value } else { 0 }))
+ }
+ }
+ )
+)
+