From 26cde3a73e59cda678c9e017536702de45c8d151 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Mon, 19 May 2025 12:54:48 -0400 Subject: [PATCH] ui: Add utility function to check if a brand is in a list Introduces `isBrandInList` to simplify checking if a given brand exists within a list of strings. This improves code clarity and avoids repetitive implementations for the same logic. --- selfdrive/ui/sunnypilot/qt/util.cc | 4 ++++ selfdrive/ui/sunnypilot/qt/util.h | 1 + 2 files changed, 5 insertions(+) diff --git a/selfdrive/ui/sunnypilot/qt/util.cc b/selfdrive/ui/sunnypilot/qt/util.cc index c729eaafd5..44139d148f 100644 --- a/selfdrive/ui/sunnypilot/qt/util.cc +++ b/selfdrive/ui/sunnypilot/qt/util.cc @@ -78,3 +78,7 @@ QMap loadPlatformList() { return _platforms; } + +bool isBrandInList(const std::string &brand, const std::vector &list) { + return std::find(list.begin(), list.end(), brand) != list.end(); +} diff --git a/selfdrive/ui/sunnypilot/qt/util.h b/selfdrive/ui/sunnypilot/qt/util.h index 0a581579e2..3192fa6b8f 100644 --- a/selfdrive/ui/sunnypilot/qt/util.h +++ b/selfdrive/ui/sunnypilot/qt/util.h @@ -18,3 +18,4 @@ QString getUserAgent(bool sunnylink = false); std::optional getSunnylinkDongleId(); std::optional getParamIgnoringDefault(const std::string ¶m_name, const std::string &default_value); QMap loadPlatformList(); +bool isBrandInList(const std::string &brand, const std::vector &list);