Reuse only the last layer after merging in layer::Stack

This commit is contained in:
Héctor Ramón Jiménez 2025-08-17 10:05:45 +02:00
parent 4d93837094
commit c1f7345ceb
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -115,7 +115,11 @@ impl<T: Layer> Stack<T> {
&& previous_layer.bounds() == current_layer.bounds()
{
previous_layer.merge(current_layer);
self.active_count -= 1;
// We can reuse the last layer
if self.current + 1 == self.active_count {
self.active_count -= 1;
}
}
}