diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-10-17 23:53:04 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-10-17 23:53:04 +0000 |
| commit | 125c9c98f78173fab40a65b5e6b455a2f0d492b4 (patch) | |
| tree | f8c35a7347af7830ba3b042bb13abe300ec425b4 /clang/lib/AST | |
| parent | fe66bf79a0e76bee70e31546edf8ac98b05e4f6c (diff) | |
| download | bcm5719-llvm-125c9c98f78173fab40a65b5e6b455a2f0d492b4.tar.gz bcm5719-llvm-125c9c98f78173fab40a65b5e6b455a2f0d492b4.zip | |
Simplify ExtVectorElementExpr::containsDuplicateElements().
llvm-svn: 84380
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 547854bb616..d9de698175a 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1744,26 +1744,20 @@ unsigned ExtVectorElementExpr::getNumElements() const { /// containsDuplicateElements - Return true if any element access is repeated. bool ExtVectorElementExpr::containsDuplicateElements() const { - const char *compStr = Accessor->getName(); - unsigned length = Accessor->getLength(); + llvm::StringRef Comp = Accessor->getNameStr(); // Halving swizzles do not contain duplicate elements. - if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") || - !strcmp(compStr, "even") || !strcmp(compStr, "odd")) + if (Comp == "hi" || Comp == "lo" || Comp == "even" || Comp == "odd") return false; // Advance past s-char prefix on hex swizzles. - if (*compStr == 's' || *compStr == 'S') { - compStr++; - length--; - } + if (Comp[0] == 's' || Comp[0] == 'S') + Comp = Comp.substr(1); - for (unsigned i = 0; i != length-1; i++) { - const char *s = compStr+i; - for (const char c = *s++; *s; s++) - if (c == *s) + for (unsigned i = 0, e = Comp.size(); i != e; ++i) + if (Comp.substr(i + 1).find(Comp[i]) != llvm::StringRef::npos) return true; - } + return false; } |

