[llvm-commits] [llvm] r84790 - /llvm/trunk/lib/VMCore/Metadata.cpp
Benjamin Kramer
benny.kra at googlemail.com
Wed Oct 21 15:55:52 PDT 2009
Author: d0k
Date: Wed Oct 21 17:55:51 2009
New Revision: 84790
URL: http://llvm.org/viewvc/llvm-project?rev=84790&view=rev
Log:
Simplify code. No intended functionality change.
Modified:
llvm/trunk/lib/VMCore/Metadata.cpp
Modified: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=84790&r1=84789&r2=84790&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (original)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Oct 21 17:55:51 2009
@@ -259,23 +259,17 @@
/// isValidName - Return true if Name is a valid custom metadata handler name.
bool MetadataContext::isValidName(const StringRef MDName) {
- const char *Name = MDName.data();
- if (!Name)
+ if (MDName.empty())
return false;
- if (!isalpha(*Name))
+ if (!isalpha(MDName[1]))
return false;
- unsigned Length = strlen(Name);
- unsigned Count = 1;
- ++Name;
- while (Name &&
- (isalnum(*Name) || *Name == '_' || *Name == '-' || *Name == '.')) {
- ++Name;
- ++Count;
+ for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E;
+ ++I) {
+ if (!isalnum(*I) && *I != '_' && *I != '-' && *I != '.')
+ return false;
}
- if (Length != Count)
- return false;
return true;
}
More information about the llvm-commits
mailing list