summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sources/scala/tools/scaladoc/ScalaSearch.java49
-rw-r--r--sources/scalac/symtab/Scope.java4
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?
*/