mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 10:50:40 +00:00
Use a single hashmap lookup to determine if a color has been resolved, and to what, instead of two lookups.
This commit is contained in:
parent
b2a0fa18ff
commit
0dfa337ba4
@ -153,12 +153,13 @@ impl Backend {
|
||||
let mut pairs = self.pairs.borrow_mut();
|
||||
|
||||
// Find if we have this color in stock
|
||||
let (front, back) = find_closest_pair(pair);
|
||||
if pairs.contains_key(&(front, back)) {
|
||||
let result = find_closest_pair(pair);
|
||||
let lookup = pairs.get(&result);
|
||||
if lookup.is_some() {
|
||||
// We got it!
|
||||
pairs[&(front, back)]
|
||||
*lookup.unwrap()
|
||||
} else {
|
||||
self.insert_color(&mut *pairs, (front, back))
|
||||
self.insert_color(&mut *pairs, result)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user