goatshriek / stumpless

a C logging library built for high performance and a rich feature set
https://goatshriek.github.io/stumpless
Apache License 2.0
443 stars 321 forks source link

Implement strcasecmp to avoid creating an uppercase copy #438

Closed Griezn closed 1 week ago

Griezn commented 3 weeks ago

When working on issue #437 I noticed that stumpless_get_facility_enum_from_bufferand stumpless_get_severity_enum_from_buffer create a copy of the parameter and then convert that copy to uppercase to compare.

As a solution I suggest implementing the strcasecomp function which performs a case-insensitive compare. And use this function to directly compare the parameter instead of its copy thus further reducing allocations and improving speed.

Maybe I am forgetting something, let me know!

goatshriek commented 3 weeks ago

I think this is a great idea, and certainly something you should feel free to implement!