Merge only contiguous layers in layer::Stack
This commit is contained in:
parent
ab04751bc4
commit
4d93837094
1 changed files with 11 additions and 7 deletions
|
|
@ -105,14 +105,18 @@ impl<T: Layer> Stack<T> {
|
||||||
|
|
||||||
let previous = self.previous.pop().unwrap();
|
let previous = self.previous.pop().unwrap();
|
||||||
|
|
||||||
let (head, tail) = self.layers.split_at_mut(previous + 1);
|
// Try to merge contiguous layers
|
||||||
let previous_layer = &mut head[previous];
|
if previous + 1 == self.current {
|
||||||
let current_layer = &mut tail[self.current - previous - 1];
|
let (head, tail) = self.layers.split_at_mut(previous + 1);
|
||||||
|
let previous_layer = &mut head[previous];
|
||||||
|
let current_layer = &mut tail[0];
|
||||||
|
|
||||||
if previous_layer.end() <= current_layer.start()
|
if previous_layer.end() <= current_layer.start()
|
||||||
&& previous_layer.bounds() == current_layer.bounds()
|
&& previous_layer.bounds() == current_layer.bounds()
|
||||||
{
|
{
|
||||||
previous_layer.merge(current_layer);
|
previous_layer.merge(current_layer);
|
||||||
|
self.active_count -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.current = previous;
|
self.current = previous;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue