Skip to content

Add string starts_with helper#532

Open
gaul wants to merge 1 commit intointel:thermald_nextfrom
gaul:starts-with
Open

Add string starts_with helper#532
gaul wants to merge 1 commit intointel:thermald_nextfrom
gaul:starts-with

Conversation

@gaul
Copy link
Contributor

@gaul gaul commented Mar 6, 2026

This is clearer and more efficient than the substr equivalent.

src/thd_sensor.h Outdated
#define SENSOR_TYPE_RAW 1

// Replacement for C++ std::string::starts_with
static bool starts_with(const std::string& s, const char *prefix) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there somewhere better to put these kind of utility functions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create thd_util.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

This is clearer and more efficient than the substr equivalent.

Signed-off-by: Andrew Gaul <andrew@gaul.org>
@gaul gaul changed the base branch from master to thermald_next March 10, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants