From 7b6cd4c234b85618eb8fcc60b81d58a402f1cef9 Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Mon, 18 May 2026 00:23:11 -0600 Subject: [PATCH] refactor(objc): use if let Some in for-loop instead of ? The `?` operator inside a `for` loop short-circuits the entire enclosing function on the first `None`, not just the current iteration. In practice `node.child(i)` returns `Some` for every `i < child_count()`, so this is harmless today, but `if let Some(child) = node.child(i)` is more defensively correct and matches the pattern used in the rest of the extractors after the Verilog sweep in #1155. Closes #1116 --- crates/codegraph-core/src/extractors/objc.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/codegraph-core/src/extractors/objc.rs b/crates/codegraph-core/src/extractors/objc.rs index 70d385e8..89993a91 100644 --- a/crates/codegraph-core/src/extractors/objc.rs +++ b/crates/codegraph-core/src/extractors/objc.rs @@ -493,13 +493,14 @@ fn collect_class_members(class_node: &Node, source: &[u8]) -> Vec { fn extract_property_name(prop_node: &Node, source: &[u8]) -> Option { let struct_decl = find_child(prop_node, "struct_declaration")?; for i in 0..struct_decl.child_count() { - let child = struct_decl.child(i)?; - if child.kind() == "struct_declarator" { - // struct_declarator > pointer_declarator > identifier - // or struct_declarator > identifier (no pointer) - let name = unwrap_property_declarator(&child, source); - if !name.is_empty() { - return Some(name); + if let Some(child) = struct_decl.child(i) { + if child.kind() == "struct_declarator" { + // struct_declarator > pointer_declarator > identifier + // or struct_declarator > identifier (no pointer) + let name = unwrap_property_declarator(&child, source); + if !name.is_empty() { + return Some(name); + } } } }