Avoid unnecessary Vec allocation in text pipeline

This commit is contained in:
Héctor Ramón Jiménez 2023-02-02 01:34:25 +01:00
parent 02fc7e6e89
commit 6b70771146
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -159,11 +159,6 @@ impl Pipeline {
})
.collect();
let buffers: Vec<_> = keys
.iter()
.map(|key| self.render_cache.get(key).expect("Get cached buffer"))
.collect();
let bounds = glyphon::TextBounds {
left: (bounds.x * scale_factor) as i32,
top: (bounds.y * scale_factor) as i32,
@ -173,8 +168,11 @@ impl Pipeline {
let text_areas: Vec<_> = sections
.iter()
.zip(buffers.iter())
.map(|(section, buffer)| {
.zip(keys.iter())
.map(|(section, key)| {
let buffer =
self.render_cache.get(key).expect("Get cached buffer");
let x = section.bounds.x * scale_factor;
let y = section.bounds.y * scale_factor;