diff options
author | cremet <cremet@epfl.ch> | 2004-07-15 13:17:18 +0000 |
---|---|---|
committer | cremet <cremet@epfl.ch> | 2004-07-15 13:17:18 +0000 |
commit | 49123a49a13f5915f142102b042414a296c6b084 (patch) | |
tree | 8ef97de23cef757a97443d3df1b8047c26d6e882 | |
parent | f4e913aa03294ecacf778fb11fabee986ced3725 (diff) | |
download | scala-49123a49a13f5915f142102b042414a296c6b084.tar.gz scala-49123a49a13f5915f142102b042414a296c6b084.tar.bz2 scala-49123a49a13f5915f142102b042414a296c6b084.zip |
- I made scaladoc use a lazy version of the sco...
- I made scaladoc use a lazy version of the scope iterator.
-rw-r--r-- | sources/scala/tools/scaladoc/ScalaSearch.java | 49 | ||||
-rw-r--r-- | sources/scalac/symtab/Scope.java | 4 |
2 files changed, 50 insertions, 3 deletions
diff --git a/sources/scala/tools/scaladoc/ScalaSearch.java b/sources/scala/tools/scaladoc/ScalaSearch.java index 94b8deaea2..c7cc9ced03 100644 --- a/sources/scala/tools/scaladoc/ScalaSearch.java +++ b/sources/scala/tools/scaladoc/ScalaSearch.java @@ -106,6 +106,46 @@ public class ScalaSearch { !isPhantom(sym); } + ////////////////////////// SCOPE ITERATOR /////////////////////////////// + + static class LazySymbolIterator extends SymbolIterator { + private Symbol[] alternatives = Symbol.EMPTY_ARRAY; + private int altindex = 0; + private int elemindex = 0; + + private Scope scope; + + public LazySymbolIterator(Scope scope) { + this.scope = scope; + scope.elements(); + } + + public boolean hasNext() { + return altindex < alternatives.length || + elemindex < scope.getElemsCache().length; + } + + public Symbol next() { + if (altindex < alternatives.length) + return alternatives[altindex++]; + else { + Symbol sym = scope.getElemsCache()[elemindex++]; + if (isLazy(sym)) + return sym; + else { + switch (sym.type()) { + case OverloadedType(Symbol[] alts, _): + alternatives = alts; + altindex = 0; + return next(); + default: + return sym; + } + } + } + } + } + ////////////////////////// TRAVERSER /////////////////////////////// /** Function from Symbol to void. @@ -132,7 +172,8 @@ public class ScalaSearch { if (isContainer(sym) && !isLazy(sym)) { List memberList = new LinkedList(); SymbolIterator i = - sym.members().iterator(); + new LazySymbolIterator(sym.members()); + //sym.members().iterator(); while (i.hasNext()) { Symbol member = i.next(); if (isRelevant(member)) @@ -164,7 +205,8 @@ public class ScalaSearch { if (isContainer(sym) && !isLazy(sym)) { List memberList = new LinkedList(); SymbolIterator i = - sym.members().iterator(); + new LazySymbolIterator(sym.members()); + //sym.members().iterator(); while (i.hasNext()) { Symbol member = i.next(); if (isDocumented.apply(member) && isRelevant(sym)) @@ -435,7 +477,8 @@ public class ScalaSearch { protected static void collectNames(Type tpe, List/*<Name>*/ names) { // local members SymbolIterator it = - tpe.members().iterator(); + new LazySymbolIterator(tpe.members()); + //tpe.members().iterator(); while (it.hasNext()) { Name name = ((Symbol) it.next()).name; if (!names.contains(name)) diff --git a/sources/scalac/symtab/Scope.java b/sources/scalac/symtab/Scope.java index f609bbf64a..ee20684da8 100644 --- a/sources/scalac/symtab/Scope.java +++ b/sources/scalac/symtab/Scope.java @@ -80,6 +80,10 @@ public class Scope { */ private Symbol[] elemsCache = null; + public Symbol[] getElemsCache() { + return elemsCache; + } + /** size and mask of hash tables * todo: make hashtables grow? */ |