mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-01 16:26:29 +00:00
Change StringRef::startswith and StringRef::endswith to versions which are a
bit more verbose, but optimize to much shorter code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91817 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -159,12 +159,14 @@ namespace llvm {
|
||||
|
||||
/// startswith - Check if this string starts with the given \arg Prefix.
|
||||
bool startswith(StringRef Prefix) const {
|
||||
return substr(0, Prefix.Length).equals(Prefix);
|
||||
return Length >= Prefix.Length &&
|
||||
memcmp(Data, Prefix.Data, Prefix.Length) == 0;
|
||||
}
|
||||
|
||||
/// endswith - Check if this string ends with the given \arg Suffix.
|
||||
bool endswith(StringRef Suffix) const {
|
||||
return slice(size() - Suffix.Length, size()).equals(Suffix);
|
||||
return Length >= Suffix.Length &&
|
||||
memcmp(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
Reference in New Issue
Block a user