From da155f882266e301ad8b02ef492970084eee0b62 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 22 Jul 2021 13:35:36 +0200 Subject: [PATCH] util/StringCompare: use [[gnu::]] attributes --- src/util/StringCompare.hxx | 27 +++++++++++++-------------- src/util/WStringCompare.hxx | 23 +++++++++++------------ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/util/StringCompare.hxx b/src/util/StringCompare.hxx index 71088bf37..283134b96 100644 --- a/src/util/StringCompare.hxx +++ b/src/util/StringCompare.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2013-2020 Max Kellermann + * Copyright 2013-2021 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,7 +32,6 @@ #include "StringView.hxx" #include "StringAPI.hxx" -#include "Compiler.h" #ifdef _UNICODE #include "WStringCompare.hxx" @@ -40,14 +39,14 @@ #include -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline bool StringIsEmpty(const char *string) noexcept { return *string == 0; } -gcc_pure +[[gnu::pure]] static inline bool StringIsEqual(std::string_view a, std::string_view b) noexcept { @@ -55,7 +54,7 @@ StringIsEqual(std::string_view a, std::string_view b) noexcept StringIsEqual(a.data(), b.data(), b.size()); } -gcc_pure +[[gnu::pure]] static inline bool StringIsEqualIgnoreCase(std::string_view a, std::string_view b) noexcept { @@ -63,18 +62,18 @@ StringIsEqualIgnoreCase(std::string_view a, std::string_view b) noexcept StringIsEqualIgnoreCase(a.data(), b.data(), b.size()); } -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline bool StringStartsWith(const char *haystack, StringView needle) noexcept { return StringIsEqual(haystack, needle.data, needle.size); } -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] bool StringEndsWith(const char *haystack, const char *needle) noexcept; -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] bool StringEndsWithIgnoreCase(const char *haystack, const char *needle) noexcept; @@ -83,7 +82,7 @@ StringEndsWithIgnoreCase(const char *haystack, const char *needle) noexcept; * does not begin with the specified prefix, this function returns * nullptr. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline const char * StringAfterPrefix(const char *haystack, StringView needle) noexcept { @@ -92,14 +91,14 @@ StringAfterPrefix(const char *haystack, StringView needle) noexcept : nullptr; } -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline bool StringStartsWithIgnoreCase(const char *haystack, StringView needle) noexcept { return StringIsEqualIgnoreCase(haystack, needle.data, needle.size); } -gcc_pure +[[gnu::pure]] static inline bool StringStartsWithIgnoreCase(StringView haystack, StringView needle) noexcept { @@ -113,7 +112,7 @@ StringStartsWithIgnoreCase(StringView haystack, StringView needle) noexcept * nullptr. * This function is case-independent. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline const char * StringAfterPrefixIgnoreCase(const char *haystack, StringView needle) noexcept { @@ -122,7 +121,7 @@ StringAfterPrefixIgnoreCase(const char *haystack, StringView needle) noexcept : nullptr; } -gcc_pure +[[gnu::pure]] static inline StringView StringAfterPrefixIgnoreCase(StringView haystack, StringView needle) noexcept @@ -136,7 +135,7 @@ StringAfterPrefixIgnoreCase(StringView haystack, * Check if the given string ends with the specified suffix. If yes, * returns the position of the suffix, and nullptr otherwise. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] const char * FindStringSuffix(const char *p, const char *suffix) noexcept; diff --git a/src/util/WStringCompare.hxx b/src/util/WStringCompare.hxx index 4b3a83f55..af4ed22f7 100644 --- a/src/util/WStringCompare.hxx +++ b/src/util/WStringCompare.hxx @@ -1,5 +1,5 @@ /* - * Copyright 2013-2020 Max Kellermann + * Copyright 2013-2021 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,20 +32,19 @@ #include "WStringView.hxx" #include "WStringAPI.hxx" -#include "Compiler.h" #include #include -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline bool StringIsEmpty(const wchar_t *string) noexcept { return *string == 0; } -gcc_pure +[[gnu::pure]] static inline bool StringIsEqual(std::wstring_view a, std::wstring_view b) noexcept { @@ -53,7 +52,7 @@ StringIsEqual(std::wstring_view a, std::wstring_view b) noexcept StringIsEqual(a.data(), b.data(), b.size()); } -gcc_pure +[[gnu::pure]] static inline bool StringIsEqualIgnoreCase(std::wstring_view a, std::wstring_view b) noexcept { @@ -61,18 +60,18 @@ StringIsEqualIgnoreCase(std::wstring_view a, std::wstring_view b) noexcept StringIsEqualIgnoreCase(a.data(), b.data(), b.size()); } -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline bool StringStartsWith(const wchar_t *haystack, WStringView needle) noexcept { return StringIsEqual(haystack, needle.data, needle.size); } -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] bool StringEndsWith(const wchar_t *haystack, const wchar_t *needle) noexcept; -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] bool StringEndsWithIgnoreCase(const wchar_t *haystack, const wchar_t *needle) noexcept; @@ -82,7 +81,7 @@ StringEndsWithIgnoreCase(const wchar_t *haystack, * does not begin with the specified prefix, this function returns * nullptr. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline const wchar_t * StringAfterPrefix(const wchar_t *haystack, WStringView needle) noexcept { @@ -91,7 +90,7 @@ StringAfterPrefix(const wchar_t *haystack, WStringView needle) noexcept : nullptr; } -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline bool StringStartsWithIgnoreCase(const wchar_t *haystack, WStringView needle) noexcept @@ -105,7 +104,7 @@ StringStartsWithIgnoreCase(const wchar_t *haystack, * nullptr. * This function is case-independent. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] static inline const wchar_t * StringAfterPrefixIgnoreCase(const wchar_t *haystack, WStringView needle) noexcept { @@ -118,7 +117,7 @@ StringAfterPrefixIgnoreCase(const wchar_t *haystack, WStringView needle) noexcep * Check if the given string ends with the specified suffix. If yes, * returns the position of the suffix, and nullptr otherwise. */ -gcc_pure gcc_nonnull_all +[[gnu::pure]] [[gnu::nonnull]] const wchar_t * FindStringSuffix(const wchar_t *p, const wchar_t *suffix) noexcept;