From da4ed75bc82957aa6fff8c6178d1f798466be8be Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Sun, 21 Nov 2021 23:55:52 +0100 Subject: [PATCH] avm2: Compare QNames by local name first --- core/src/avm2/names.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/avm2/names.rs b/core/src/avm2/names.rs index faa221767..a3c3b26ee 100644 --- a/core/src/avm2/names.rs +++ b/core/src/avm2/names.rs @@ -139,13 +139,22 @@ impl<'gc> Namespace<'gc> { /// `QName`. All other forms of names and multinames are either versions of /// `QName` with unspecified parameters, or multiple names to be checked in /// order. -#[derive(Clone, Collect, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Collect, Debug, Hash)] #[collect(no_drop)] pub struct QName<'gc> { ns: Namespace<'gc>, name: AvmString<'gc>, } +impl<'gc> PartialEq for QName<'gc> { + fn eq(&self, other: &Self) -> bool { + // Implemented by hand to enforce order of comparisons for perf + self.name == other.name && self.ns == other.ns + } +} + +impl<'gc> Eq for QName<'gc> {} + impl<'gc> QName<'gc> { pub fn new(ns: Namespace<'gc>, name: impl Into>) -> Self { Self {