core: refactor to make use of equality implementation

This commit is contained in:
Will Brindle 2019-10-08 21:36:50 +01:00
parent 70b7b1c807
commit f84f807bf1
1 changed files with 1 additions and 9 deletions

View File

@ -1523,15 +1523,7 @@ impl<'gc> Avm1<'gc> {
// The same as normal equality but types must match
let a = self.pop()?;
let b = self.pop()?;
let result = match (b, a) {
(Value::Undefined, Value::Undefined) => true,
(Value::Null, Value::Null) => true,
(Value::Number(a), Value::Number(b)) => a == b || (a.is_nan() && b.is_nan()),
(Value::String(a), Value::String(b)) => a == b,
(Value::Bool(a), Value::Bool(b)) => a == b,
(Value::Object(_a), Value::Object(_b)) => false, // TODO
_ => false,
};
let result = a == b;
self.push(Value::Bool(result));
Ok(())
}