summaryrefslogtreecommitdiffstats
path: root/src/dirty.rs
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-03-16 22:49:27 +0100
committerrabite <rabite@posteo.de>2019-03-17 00:19:58 +0100
commit8b1c4db9cfa2ea0bf02e9e96c29b2510bbc391af (patch)
treef3c2b0e857691ae968d54269a0cd3b8067d36dbc /src/dirty.rs
parent33a9562379b9d6fdd7be19ce20b3a5ac1fa7e1c7 (diff)
big performance improvement
Diffstat (limited to 'src/dirty.rs')
-rw-r--r--src/dirty.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/dirty.rs b/src/dirty.rs
new file mode 100644
index 0000000..fe6e4d1
--- /dev/null
+++ b/src/dirty.rs
@@ -0,0 +1,35 @@
+#[derive(PartialEq, Eq, Hash, Clone, Debug)]
+pub struct DirtyBit(bool);
+
+pub trait Dirtyable {
+ fn get_bit(&self) -> &DirtyBit;
+ fn get_bit_mut(&mut self) -> &mut DirtyBit;
+
+ fn is_dirty(&self) -> bool {
+ self.get_bit().0
+ }
+
+ fn set_dirty(&mut self) {
+ self.get_bit_mut().0 = true;
+ }
+ fn set_clean(&mut self) {
+ self.get_bit_mut().0 = false;
+ }
+}
+
+
+impl DirtyBit {
+ pub fn new() -> DirtyBit {
+ DirtyBit(false)
+ }
+}
+
+
+impl Dirtyable for DirtyBit {
+ fn get_bit(&self) -> &DirtyBit {
+ self
+ }
+ fn get_bit_mut(&mut self) -> &mut DirtyBit {
+ self
+ }
+}