Skip to content

Commit

Permalink
Update loop termination conditions for label comparison
Browse files Browse the repository at this point in the history
Refine the label comparison loop by adding a termination condition using the actual end of the `item_label`, enhancing clarity and safety. Includes a TODO comment suggesting further improvement with constrained algorithms.
  • Loading branch information
inakleinbottle committed Nov 4, 2024
1 parent 55c6e85 commit bc23d43
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion streams/src/schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ bool StreamSchema::compare_labels(

if (item_label.empty()) { return false; }

// TODO: Replace with constrained algorithm when ranges is imported
auto lit = item_label.begin();
auto rit = ref_label.begin();
const auto lend = item_label.end();

for (; *lit != '\0'; ++lit, ++rit) {
for (; lit != lend && *lit != '\0'; ++lit, ++rit) {
if (*rit != *lit) { return false; }
}

Expand Down

0 comments on commit bc23d43

Please sign in to comment.