mirror of
https://github.com/RGBCube/cstree
synced 2025-07-27 17:17:45 +00:00
Change SyntaxNode
's Hash
and Eq
to be based on pointer equality (#15)
This commit is contained in:
parent
d67c18cc11
commit
f6905735eb
2 changed files with 3 additions and 9 deletions
|
@ -5,7 +5,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use fxhash::FxHasher32;
|
use fxhash::FxHasher32;
|
||||||
use servo_arc::{Arc, HeaderSlice, HeaderWithLength, ThinArc};
|
use servo_arc::{Arc, HeaderWithLength, ThinArc};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
green::{GreenElement, GreenElementRef, PackedGreenElement, SyntaxKind},
|
green::{GreenElement, GreenElementRef, PackedGreenElement, SyntaxKind},
|
||||||
|
@ -122,11 +122,6 @@ impl GreenNode {
|
||||||
inner: self.data.slice.iter(),
|
inner: self.data.slice.iter(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn ptr(&self) -> *const u8 {
|
|
||||||
let r: &HeaderSlice<_, _> = &self.data;
|
|
||||||
r as *const _ as _
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hash for GreenNode {
|
impl Hash for GreenNode {
|
||||||
|
|
|
@ -185,7 +185,7 @@ impl<L: Language, D, R> SyntaxNode<L, D, R> {
|
||||||
// Identity semantics for hash & eq
|
// Identity semantics for hash & eq
|
||||||
impl<L: Language, D, R> PartialEq for SyntaxNode<L, D, R> {
|
impl<L: Language, D, R> PartialEq for SyntaxNode<L, D, R> {
|
||||||
fn eq(&self, other: &SyntaxNode<L, D, R>) -> bool {
|
fn eq(&self, other: &SyntaxNode<L, D, R>) -> bool {
|
||||||
self.green().ptr() == other.green().ptr() && self.text_range().start() == other.text_range().start()
|
self.data == other.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,8 +193,7 @@ impl<L: Language, D, R> Eq for SyntaxNode<L, D, R> {}
|
||||||
|
|
||||||
impl<L: Language, D, R> Hash for SyntaxNode<L, D, R> {
|
impl<L: Language, D, R> Hash for SyntaxNode<L, D, R> {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
ptr::hash(self.green().ptr(), state);
|
ptr::hash(self.data, state);
|
||||||
self.text_range().start().hash(state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue