r184168 - ArrayRef'ize CodeCompletionContext::getNumSelIdents()
David Blaikie
dblaikie at gmail.com
Mon Jun 17 21:27:39 PDT 2013
On Mon, Jun 17, 2013 at 9:02 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> Author: gribozavr
> Date: Mon Jun 17 23:02:26 2013
> New Revision: 184168
>
> URL: http://llvm.org/viewvc/llvm-project?rev=184168&view=rev
> Log:
> ArrayRef'ize CodeCompletionContext::getNumSelIdents()
>
> Modified:
> cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
> cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
>
> Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=184168&r1=184167&r2=184168&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
> +++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Mon Jun 17 23:02:26 2013
> @@ -303,10 +303,7 @@ public:
> QualType getBaseType() const { return BaseType; }
>
> /// \brief Retrieve the Objective-C selector identifiers.
> - IdentifierInfo * const *getSelIdents() const { return SelIdents.data(); }
> -
> - /// \brief Retrieve the number of Objective-C selector identifiers.
> - unsigned getNumSelIdents() const { return SelIdents.size(); }
> + ArrayRef<IdentifierInfo *> getSelIdents() const { return SelIdents; }
>
> /// \brief Determines whether we want C++ constructors as results within this
> /// context.
>
> Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=184168&r1=184167&r2=184168&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
> +++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Mon Jun 17 23:02:26 2013
> @@ -562,15 +562,13 @@ namespace {
> AllocatedResults.Contexts = getContextsForContextKind(contextKind, S);
>
> AllocatedResults.Selector = "";
> - if (Context.getNumSelIdents() > 0) {
> - for (unsigned i = 0; i < Context.getNumSelIdents(); i++) {
> - IdentifierInfo *selIdent = Context.getSelIdents()[i];
> - if (selIdent != NULL) {
> - StringRef selectorString = Context.getSelIdents()[i]->getName();
> - AllocatedResults.Selector += selectorString;
> - }
> - AllocatedResults.Selector += ":";
> + for (unsigned i = 0, e = Context.getSelIdents().size(); i != e; i++) {
Might be nicer to use iterators here? rather than having to write
out/call Context.getSelIdents() a couple of times on each iteration.
> + IdentifierInfo *selIdent = Context.getSelIdents()[i];
> + if (selIdent != NULL) {
& while you're here, this could be written with a declaration inside
the condition:
if (IdentifierInfo *selIdent = *I) {
> + StringRef selectorString = Context.getSelIdents()[i]->getName();
& why does this access the array again rather than using selIdent directly?
> + AllocatedResults.Selector += selectorString;
Could probably just fold it in here easily enough then:
for (ArrayRef<IdentifierInfo*>::iterator I =
Context.getSelIdents().begin(), E = Context.getSelIdents().end(); I !=
E; ++I)
if (*I)
AllocatedResults.Selector += (*I)->getName();
?
> }
> + AllocatedResults.Selector += ":";
> }
>
> QualType baseType = Context.getBaseType();
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list