Skip to content

Commit 2a1ea15

Browse files
Use StringRef::starts_with (NFC) (#94112)
1 parent 8256c59 commit 2a1ea15

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static bool IsTrivialBasename(const llvm::StringRef &basename) {
152152
// because it is significantly more efficient then using the general purpose
153153
// regular expression library.
154154
size_t idx = 0;
155-
if (basename.size() > 0 && basename[0] == '~')
155+
if (basename.starts_with('~'))
156156
idx = 1;
157157

158158
if (basename.size() <= idx)

lldb/source/Utility/UriParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ std::optional<URI> URI::Parse(llvm::StringRef uri) {
4747
((path_pos != std::string::npos) ? path_pos : uri.size()) - host_pos);
4848

4949
// Extract hostname
50-
if (!host_port.empty() && host_port[0] == '[') {
50+
if (host_port.starts_with('[')) {
5151
// hostname is enclosed with square brackets.
5252
pos = host_port.rfind(']');
5353
if (pos == std::string::npos)

llvm/lib/MC/MCExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens) const {
7676
// Parenthesize names that start with $ so that they don't look like
7777
// absolute names.
7878
bool UseParens = MAI && MAI->useParensForDollarSignNames() && !InParens &&
79-
!Sym.getName().empty() && Sym.getName()[0] == '$';
79+
Sym.getName().starts_with('$');
8080

8181
if (UseParens) {
8282
OS << '(';

0 commit comments

Comments
 (0)