Skip to content

Commit

Permalink
nuon: Stack allocated vectors for small rows and columns
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex committed Nov 24, 2024
1 parent c22782e commit 501234e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions nuon/src/widget/column.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use smallvec::SmallVec;

use crate::{Element, Event, LayoutCtx, Node, RenderCtx, Renderer, UpdateCtx, Widget};

pub struct Column<'a, MSG> {
children: Vec<Element<'a, MSG>>,
children: SmallVec<[Element<'a, MSG>; 4]>,
gap: f32,
}

Expand All @@ -14,7 +16,7 @@ impl<'a, MSG> Default for Column<'a, MSG> {
impl<'a, MSG> Column<'a, MSG> {
pub fn new() -> Self {
Self {
children: Vec::new(),
children: SmallVec::new(),
gap: 0.0,
}
}
Expand Down
6 changes: 4 additions & 2 deletions nuon/src/widget/row.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use smallvec::SmallVec;

use crate::{Element, Event, LayoutCtx, Node, RenderCtx, Renderer, UpdateCtx, Widget};

pub struct Row<'a, MSG> {
children: Vec<Element<'a, MSG>>,
children: SmallVec<[Element<'a, MSG>; 4]>,
gap: f32,
}

Expand All @@ -14,7 +16,7 @@ impl<'a, MSG> Default for Row<'a, MSG> {
impl<'a, MSG> Row<'a, MSG> {
pub fn new() -> Self {
Self {
children: Vec::new(),
children: SmallVec::new(),
gap: 0.0,
}
}
Expand Down
6 changes: 4 additions & 2 deletions nuon/src/widget/stack.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use smallvec::SmallVec;

use crate::{Element, Event, LayoutCtx, Node, RenderCtx, Renderer, UpdateCtx, Widget};

pub struct Stack<'a, MSG> {
children: Vec<Element<'a, MSG>>,
children: SmallVec<[Element<'a, MSG>; 4]>,
}

impl<'a, MSG> Default for Stack<'a, MSG> {
Expand All @@ -13,7 +15,7 @@ impl<'a, MSG> Default for Stack<'a, MSG> {
impl<'a, MSG> Stack<'a, MSG> {
pub fn new() -> Self {
Self {
children: Vec::new(),
children: SmallVec::new(),
}
}

Expand Down

0 comments on commit 501234e

Please sign in to comment.