summaryrefslogtreecommitdiff
path: root/engine/src/file_format/wavefront/common.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-08-25 15:41:40 +0200
committerHampusM <hampus@hampusmat.com>2026-08-25 15:41:40 +0200
commit4d011687e5e65b97168610659bc79330983cf59b (patch)
tree69166d4ba315e0c749305dee1a1f851a557093ca /engine/src/file_format/wavefront/common.rs
parente8df35e08e43b0fe4178267544bb0a0834267598 (diff)
perf(engine): optimize wavefront obj parsing
Diffstat (limited to 'engine/src/file_format/wavefront/common.rs')
-rw-r--r--engine/src/file_format/wavefront/common.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/engine/src/file_format/wavefront/common.rs b/engine/src/file_format/wavefront/common.rs
index 8cdfb34..83fd8af 100644
--- a/engine/src/file_format/wavefront/common.rs
+++ b/engine/src/file_format/wavefront/common.rs
@@ -1,5 +1,7 @@
use std::num::{ParseFloatError, ParseIntError};
+use engine_ecs::util::array_vec::ArrayVec;
+
macro_rules! keyword {
(
$(#[$attr: meta])*
@@ -68,9 +70,11 @@ where
let mut parts = line.split(' ');
let keyword = KeywordT::from_str(parts.next().unwrap(), line_no)?;
- let arguments = parts
- .map(|part| Value::parse::<KeywordT>(part, line_no))
- .collect::<Result<Vec<_>, _>>()?;
+ let mut arguments = ArrayVec::<Value, 16>::default();
+
+ for part in parts {
+ arguments.push(Value::parse::<KeywordT>(part, line_no)?);
+ }
Ok(Some(Statement { keyword, arguments }))
}
@@ -265,7 +269,7 @@ impl Value
pub struct Statement<KeywordT: Keyword>
{
pub keyword: KeywordT,
- pub arguments: Vec<Value>,
+ pub arguments: ArrayVec<Value, 16>,
}
impl<KeywordT: Keyword> Statement<KeywordT>