Skip to content

Use StringRef::starts_with (NFC) #94112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static bool IsTrivialBasename(const llvm::StringRef &basename) {
// because it is significantly more efficient then using the general purpose
// regular expression library.
size_t idx = 0;
if (basename.size() > 0 && basename[0] == '~')
if (basename.starts_with('~'))
idx = 1;

if (basename.size() <= idx)
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Utility/UriParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ std::optional<URI> URI::Parse(llvm::StringRef uri) {
((path_pos != std::string::npos) ? path_pos : uri.size()) - host_pos);

// Extract hostname
if (!host_port.empty() && host_port[0] == '[') {
if (host_port.starts_with('[')) {
// hostname is enclosed with square brackets.
pos = host_port.rfind(']');
if (pos == std::string::npos)
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/MC/MCExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens) const {
// Parenthesize names that start with $ so that they don't look like
// absolute names.
bool UseParens = MAI && MAI->useParensForDollarSignNames() && !InParens &&
!Sym.getName().empty() && Sym.getName()[0] == '$';
Sym.getName().starts_with('$');

if (UseParens) {
OS << '(';
Expand Down
Loading