gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 8TOML 3CSS 1317 Definiciones

Replace ref_eq with Rc::ptr_eq

3f589d0463a0763fbce8ee1d2f1057ec535fd8d1 · por Emil Sjölander · (hace 7 años) · padre 67bad4210 · ver el árbol en este commit

Delta semántico · 3

src/algo.rs

src/lib.rs

src/ref_eq.rs

3 archivos · +2 −11

diff --git a/src/algo.rs b/src/algo.rs
index 8bad9cf99..fcda13b90 100644
--- a/src/algo.rs
+++ b/src/algo.rs
@@ -13,8 +13,6 @@ use crate::result;
 use crate::result::Result;
 use crate::style::*;
 
-use crate::ref_eq::ref_eq;
-
 use crate::number::Number::*;
 use crate::number::*;
 
@@ -741,7 +739,7 @@ fn compute_internal(
             )?;
 
             child.baseline = calc_baseline(&result::Layout {
-                order: node.children.iter().position(|n| ref_eq(n, child.node)).unwrap() as u32,
+                order: node.children.iter().position(|n| Rc::ptr_eq(n, child.node)).unwrap() as u32,
                 size: result.size,
                 location: Point { x: 0.0, y: 0.0 },
                 children: result.children,
@@ -1144,7 +1142,7 @@ fn compute_internal(
                     + (child.position.cross_start(dir).or_else(0.0) - child.position.cross_end(dir).or_else(0.0));
 
                 children.push(result::Layout {
-                    order: node.children.iter().position(|n| ref_eq(n, child.node)).unwrap() as u32,
+                    order: node.children.iter().position(|n| Rc::ptr_eq(n, child.node)).unwrap() as u32,
                     size: result.size,
                     location: Point {
                         x: if is_row { offset_main } else { offset_cross },
@@ -1345,7 +1343,6 @@ fn compute_internal(
         .collect();
 
     children.append(&mut hidden_children);
-
     children.sort_by(|c1, c2| c1.order.cmp(&c2.order));
 
     let result = ComputeResult { size: container_size, children };
diff --git a/src/lib.rs b/src/lib.rs
index 69ede42a9..2b10ee293 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,4 +10,3 @@ pub mod result;
 pub mod style;
 
 mod algo;
-mod ref_eq;
diff --git a/src/ref_eq.rs b/src/ref_eq.rs
deleted file mode 100644
index 40b584e42..000000000
--- a/src/ref_eq.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-/// Determine if two borrowed pointers point to the same thing.
-#[inline]
-pub fn ref_eq<T>(thing: &T, other: &T) -> bool {
-    (thing as *const T) == (other as *const T)
-}