Avoid repeated channel alias parsing in constrained companions

This commit is contained in:
mikecarper committed 2026-10-28 03:03:48 -07:00
1 parent eb7c307583
commit 3385f2acaa
5 files changed
+25 -9

No files matched your search

+6 -3
View File
@@ -34,9 +34,12 @@ inline CompanionChannelAlias parseCompanionChannelAlias(const char* name) {
// Only exact named radio2 aliases request RF setup. Ordinary channels and
// arbitrary r2 labels keep the operator's existing profile.
inline const char* companionChannelRadio2Preset(const char* name) {
const auto alias = parseCompanionChannelAlias(name);
return alias.kind == CompanionChannelKind::Radio2
&& mesh::cli::radio2PresetTuple(alias.tail) ? alias.tail : nullptr;
if (!name) return nullptr;
if (*name == '#') ++name;
if (strncmp(name, "r2-", 3)) return nullptr;
name += 3;
// An exact preset tail also excludes every invalid/nested alias form.
return mesh::cli::radio2PresetTuple(name) ? name : nullptr;
}
inline bool companionChannelCanonicalName(const char* name, char* out, size_t size) {