Skip to content

Commit 7470131

Browse files
[llvm] Use StringRef::consume_front (NFC) (llvm#139458)
1 parent b4b0533 commit 7470131

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

llvm/lib/Support/APFloat.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,9 +3262,8 @@ bool IEEEFloat::convertFromStringSpecials(StringRef str) {
32623262
return true;
32633263
}
32643264

3265-
bool IsNegative = str.front() == '-';
3265+
bool IsNegative = str.consume_front("-");
32663266
if (IsNegative) {
3267-
str = str.drop_front();
32683267
if (str.size() < MIN_NAME_SIZE)
32693268
return false;
32703269

@@ -3275,16 +3274,13 @@ bool IEEEFloat::convertFromStringSpecials(StringRef str) {
32753274
}
32763275

32773276
// If we have a 's' (or 'S') prefix, then this is a Signaling NaN.
3278-
bool IsSignaling = str.front() == 's' || str.front() == 'S';
3277+
bool IsSignaling = str.consume_front_insensitive("s");
32793278
if (IsSignaling) {
3280-
str = str.drop_front();
32813279
if (str.size() < MIN_NAME_SIZE)
32823280
return false;
32833281
}
32843282

3285-
if (str.starts_with("nan") || str.starts_with("NaN")) {
3286-
str = str.drop_front(3);
3287-
3283+
if (str.consume_front("nan") || str.consume_front("NaN")) {
32883284
// A NaN without payload.
32893285
if (str.empty()) {
32903286
makeNaN(IsSignaling, IsNegative);

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,10 +1632,8 @@ SPIRVType *SPIRVGlobalRegistry::getOrCreateSPIRVTypeByName(
16321632
auto SpirvTy = getOrCreateSPIRVType(Ty, MIRBuilder, AQ, false, true);
16331633

16341634
// Handle "type*" or "type* vector[N]".
1635-
if (TypeStr.starts_with("*")) {
1635+
if (TypeStr.consume_front("*"))
16361636
SpirvTy = getOrCreateSPIRVPointerType(Ty, MIRBuilder, SC);
1637-
TypeStr = TypeStr.substr(strlen("*"));
1638-
}
16391637

16401638
// Handle "typeN*" or "type vector[N]*".
16411639
bool IsPtrToVec = TypeStr.consume_back("*");

0 commit comments

Comments
 (0)