util/StringView: use [[gnu::]] attributes
This commit is contained in:
parent
da155f8822
commit
672278e5fd
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2020 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2013-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -103,12 +103,12 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
return {start, size_t(data + size - start)};
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
pointer Find(value_type ch) const noexcept {
|
||||
return StringFind(data, ch, this->size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
pointer FindLast(value_type ch) const noexcept {
|
||||
return StringFindLast(data, ch, size);
|
||||
}
|
||||
@ -118,7 +118,7 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
* character. If the character is not found, then the first
|
||||
* value is the whole string and the second value is nullptr.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
std::pair<BasicStringView<T>, BasicStringView<T>> Split(value_type ch) const noexcept {
|
||||
const auto separator = Find(ch);
|
||||
if (separator == nullptr)
|
||||
@ -132,7 +132,7 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
* character. If the character is not found, then the first
|
||||
* value is the whole string and the second value is nullptr.
|
||||
*/
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
std::pair<BasicStringView<T>, BasicStringView<T>> SplitLast(value_type ch) const noexcept {
|
||||
const auto separator = FindLast(ch);
|
||||
if (separator == nullptr)
|
||||
@ -141,30 +141,30 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
return {{begin(), separator}, {separator + 1, end()}};
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool StartsWith(BasicStringView<T> needle) const noexcept {
|
||||
return this->size >= needle.size &&
|
||||
StringIsEqual(data, needle.data, needle.size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool EndsWith(BasicStringView<T> needle) const noexcept {
|
||||
return this->size >= needle.size &&
|
||||
StringIsEqual(data + this->size - needle.size,
|
||||
needle.data, needle.size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool StartsWith(value_type ch) const noexcept {
|
||||
return !empty() && front() == ch;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool EndsWith(value_type ch) const noexcept {
|
||||
return !empty() && back() == ch;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
int Compare(BasicStringView<T> other) const noexcept {
|
||||
if (size < other.size) {
|
||||
int result = StringCompare(data, other.data, size);
|
||||
@ -181,26 +181,26 @@ struct BasicStringView : ConstBuffer<T> {
|
||||
return StringCompare(data, other.data, size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool Equals(BasicStringView<T> other) const noexcept {
|
||||
return this->size == other.size &&
|
||||
StringIsEqual(data, other.data, this->size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool StartsWithIgnoreCase(BasicStringView<T> needle) const noexcept {
|
||||
return this->size >= needle.size &&
|
||||
StringIsEqualIgnoreCase(data, needle.data, needle.size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool EndsWithIgnoreCase(BasicStringView<T> needle) const noexcept {
|
||||
return this->size >= needle.size &&
|
||||
StringIsEqualIgnoreCase(data + this->size - needle.size,
|
||||
needle.data, needle.size);
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
[[gnu::pure]]
|
||||
bool EqualsIgnoreCase(BasicStringView<T> other) const noexcept {
|
||||
return this->size == other.size &&
|
||||
StringIsEqualIgnoreCase(data, other.data, this->size);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2013-2021 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
Loading…
Reference in New Issue
Block a user