Change lookup order for -s vs prefixes

This commit is contained in:
Tiffany Bennett 2016-08-25 21:59:42 -04:00
parent eb185656dd
commit 755c853cc7

View file

@ -174,11 +174,6 @@ impl Context {
return Some(Number(Number::one().0, unit.clone()))
}
}
if name.ends_with("s") {
if let Some(v) = self.lookup(&name[0..name.len()-1]) {
return Some(v)
}
}
for &(ref pre, ref value) in &self.prefixes {
if name.starts_with(pre) {
if let Some(v) = self.lookup(&name[pre.len()..]) {
@ -186,6 +181,11 @@ impl Context {
}
}
}
if name.ends_with("s") {
if let Some(v) = self.lookup(&name[0..name.len()-1]) {
return Some(v)
}
}
None
}
@ -207,11 +207,6 @@ impl Context {
// we cannot canonicalize it further
return None
}
if name.ends_with("s") {
if let Some(v) = self.canonicalize(&name[0..name.len()-1]) {
return Some(v)
}
}
for &(ref pre, ref val) in &self.prefixes {
if name.starts_with(pre) {
if let Some(v) = self.canonicalize(&name[pre.len()..]) {
@ -225,6 +220,11 @@ impl Context {
}
}
}
if name.ends_with("s") {
if let Some(v) = self.canonicalize(&name[0..name.len()-1]) {
return Some(v)
}
}
None
}
@ -837,12 +837,6 @@ impl Context {
self.visit(&unit);
return Some(())
}
if name.ends_with("s") {
let v = Rc::new(name[0..name.len()-1].to_owned());
if let Some(()) = self.lookup(&v) {
return Some(())
}
}
let mut found = vec![];
for (pre, _) in &self.input {
if let &Name::Prefix(ref pre) = pre {
@ -858,6 +852,12 @@ impl Context {
return Some(())
}
}
if name.ends_with("s") {
let v = Rc::new(name[0..name.len()-1].to_owned());
if let Some(()) = self.lookup(&v) {
return Some(())
}
}
None
}