Skip to content

Commit

Permalink
Merge pull request #6620 from lrytz/strawman520
Browse files Browse the repository at this point in the history
Remove () from iterator
  • Loading branch information
lrytz authored May 14, 2018
2 parents 6fcad4d + 1587fd6 commit e2094bf
Show file tree
Hide file tree
Showing 139 changed files with 696 additions and 696 deletions.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/backend/jvm/AsmUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ object AsmUtils {
/**
* Returns a human-readable representation of the given instruction sequence.
*/
def textify(insns: InsnList): String = textify(insns.iterator().asScala)
def textify(insns: InsnList): String = textify(insns.iterator.asScala)

/**
* Run ASM's CheckClassAdapter over a class. Returns None if no problem is found, otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ abstract class BCodeIdiomatic {
implicit class InsnIterInsnList(lst: asm.tree.InsnList) {

@inline final def foreachInsn(f: (asm.tree.AbstractInsnNode) => Unit): Unit = {
val insnIter = lst.iterator()
val insnIter = lst.iterator
while (insnIter.hasNext) {
f(insnIter.next())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ abstract class BackendUtils extends PerRunInit {
}
}

val tcbIt = method.tryCatchBlocks.iterator()
val tcbIt = method.tryCatchBlocks.iterator
while (tcbIt.hasNext) {
val tcb = tcbIt.next()
enqInsn(tcb.handler, 1)
Expand Down Expand Up @@ -641,7 +641,7 @@ object BackendUtils {
m.exceptions.asScala foreach visitInternalName
for (tcb <- m.tryCatchBlocks.asScala) visitInternalName(tcb.`type`)

val iter = m.instructions.iterator()
val iter = m.instructions.iterator
while (iter.hasNext) iter.next() match {
case ti: TypeInsnNode => visitInternalNameOrArrayReference(ti.desc)
case fi: FieldInsnNode => visitInternalNameOrArrayReference(fi.owner); visitDescriptor(fi.desc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@ object BytecodeUtils {
}

def removeLineNumberNodes(instructions: InsnList): Unit = {
val iter = instructions.iterator()
val iter = instructions.iterator
while (iter.hasNext) iter.next() match {
case _: LineNumberNode => iter.remove()
case _ =>
}
}

def cloneLabels(methodNode: MethodNode): Map[LabelNode, LabelNode] = {
methodNode.instructions.iterator().asScala.collect({
methodNode.instructions.iterator.asScala.collect({
case labelNode: LabelNode => (labelNode, newLabelNode)
}).toMap
}
Expand All @@ -322,7 +322,7 @@ object BytecodeUtils {
* according to the `labelMap`.
*/
def cloneLocalVariableNodes(methodNode: MethodNode, labelMap: Map[LabelNode, LabelNode], calleeMethodName: String, shift: Int): List[LocalVariableNode] = {
methodNode.localVariables.iterator().asScala.map(localVariable => {
methodNode.localVariables.iterator.asScala.map(localVariable => {
val name =
if (calleeMethodName.length + localVariable.name.length < BTypes.InlinedLocalVariablePrefixMaxLength) {
calleeMethodName + "_" + localVariable.name
Expand Down Expand Up @@ -355,7 +355,7 @@ object BytecodeUtils {
* labels according to the `labelMap`.
*/
def cloneTryCatchBlockNodes(methodNode: MethodNode, labelMap: Map[LabelNode, LabelNode]): List[TryCatchBlockNode] = {
methodNode.tryCatchBlocks.iterator().asScala.map(tryCatch => new TryCatchBlockNode(
methodNode.tryCatchBlocks.iterator.asScala.map(tryCatch => new TryCatchBlockNode(
labelMap(tryCatch.start),
labelMap(tryCatch.end),
labelMap(tryCatch.handler),
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/backend/jvm/opt/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ abstract class Inliner {
// large methods are not added to the call graph.
val analyzer = new AsmAnalyzer(callee, calleeDeclarationClass.internalName)

for (originalReturn <- callee.instructions.iterator().asScala if isReturn(originalReturn)) {
for (originalReturn <- callee.instructions.iterator.asScala if isReturn(originalReturn)) {
val frame = analyzer.frameAt(originalReturn)
var stackHeight = frame.getStackSize

Expand Down
18 changes: 9 additions & 9 deletions src/compiler/scala/tools/nsc/backend/jvm/opt/LocalOpt.scala
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ abstract class LocalOpt {
// cannot change instructions while iterating, it gets the analysis out of synch (indexed by instructions)
val toReplace = mutable.Map.empty[AbstractInsnNode, List[AbstractInsnNode]]

val it = method.instructions.iterator()
val it = method.instructions.iterator
while (it.hasNext) it.next() match {
case vi: VarInsnNode if isNull(vi, vi.`var`) =>
if (vi.getOpcode == ALOAD)
Expand Down Expand Up @@ -506,7 +506,7 @@ abstract class LocalOpt {
var changed = false
var maxLocals = parametersSize(method)
var maxStack = 0
val itr = method.instructions.iterator()
val itr = method.instructions.iterator
while (itr.hasNext) {
val insn = itr.next()
val isLive = frames(i) != null
Expand Down Expand Up @@ -568,7 +568,7 @@ abstract class LocalOpt {
// cannot remove instructions while iterating, it gets the analysis out of synch (indexed by instructions)
val toRemove = mutable.Set.empty[TypeInsnNode]

val it = method.instructions.iterator()
val it = method.instructions.iterator
while (it.hasNext) it.next() match {
case ti: TypeInsnNode if ti.getOpcode == CHECKCAST =>
val frame = typeAnalyzer.frameAt(ti)
Expand Down Expand Up @@ -614,7 +614,7 @@ object LocalOptImpls {

var result: RemoveHandlersResult = RemoveHandlersResult.NoneRemoved

val handlersIter = method.tryCatchBlocks.iterator()
val handlersIter = method.tryCatchBlocks.iterator
while (handlersIter.hasNext) {
val handler = handlersIter.next()
if (!containsExecutableCode(handler.start, handler.end)) {
Expand Down Expand Up @@ -661,7 +661,7 @@ object LocalOptImpls {
}

val initialNumVars = method.localVariables.size
val localsIter = method.localVariables.iterator()
val localsIter = method.localVariables.iterator
while (localsIter.hasNext) {
val local = localsIter.next()
val index = local.index
Expand Down Expand Up @@ -707,7 +707,7 @@ object LocalOptImpls {

val firstLocalIndex = parametersSize(method)
for (i <- 0 until firstLocalIndex) renumber += i // parameters and `this` are always used.
method.instructions.iterator().asScala foreach {
method.instructions.iterator.asScala foreach {
case VarInstruction(varIns, slot) => addVar(varIns, slot)
case _ =>
}
Expand All @@ -728,7 +728,7 @@ object LocalOptImpls {
else {
// update variable instructions according to the renumber table
method.maxLocals = nextIndex
method.instructions.iterator().asScala.foreach {
method.instructions.iterator.asScala.foreach {
case VarInstruction(varIns, slot) =>
val oldIndex = slot
if (oldIndex >= firstLocalIndex && renumber(oldIndex) != oldIndex) varIns match {
Expand Down Expand Up @@ -759,7 +759,7 @@ object LocalOptImpls {
}

val initialSize = method.instructions.size
val iterator = method.instructions.iterator()
val iterator = method.instructions.iterator
var previousLabel: LabelNode = null
while (iterator.hasNext) {
iterator.next match {
Expand Down Expand Up @@ -788,7 +788,7 @@ object LocalOptImpls {

val jumpInsns = mutable.LinkedHashMap.empty[JumpInsnNode, Boolean]

for (insn <- method.instructions.iterator().asScala) insn match {
for (insn <- method.instructions.iterator.asScala) insn match {
case l: LabelNode =>
activeHandlers ++= allHandlers.filter(_.start == l)
activeHandlers = activeHandlers.filter(_.end != l)
Expand Down
14 changes: 7 additions & 7 deletions src/compiler/scala/tools/nsc/classpath/DirectoryClassPath.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No

// e.g. "java.lang" -> Seq("/modules/java.base")
private val packageToModuleBases: Map[String, Seq[Path]] = {
val ps = Files.newDirectoryStream(dir).iterator().asScala
val ps = Files.newDirectoryStream(dir).iterator.asScala
def lookup(pack: Path): Seq[Path] = {
Files.list(pack).iterator().asScala.map(l => if (Files.isSymbolicLink(l)) Files.readSymbolicLink(l) else l).toList
Files.list(pack).iterator.asScala.map(l => if (Files.isSymbolicLink(l)) Files.readSymbolicLink(l) else l).toList
}
ps.map(p => (p.toString.stripPrefix("/packages/"), lookup(p))).toMap
}
Expand All @@ -192,7 +192,7 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No
if (inPackage == "") Nil
else {
packageToModuleBases.getOrElse(inPackage, Nil).flatMap(x =>
Files.list(x.resolve(inPackage.replace('.', '/'))).iterator().asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x =>
Files.list(x.resolve(inPackage.replace('.', '/'))).iterator.asScala.filter(_.getFileName.toString.endsWith(".class"))).map(x =>
ClassFileEntryImpl(new PlainNioFile(x))).toVector
}
}
Expand Down Expand Up @@ -225,8 +225,8 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
import java.nio.file.Path, java.nio.file._

private val fileSystem: FileSystem = FileSystems.newFileSystem(ctSym, null)
private val root: Path = fileSystem.getRootDirectories.iterator().next
private val roots = Files.newDirectoryStream(root).iterator().asScala.toList
private val root: Path = fileSystem.getRootDirectories.iterator.next
private val roots = Files.newDirectoryStream(root).iterator.asScala.toList

// http://mail.openjdk.java.net/pipermail/compiler-dev/2018-March/011737.html
private def codeFor(major: Int): String = if (major < 10) major.toString else ('A' + (major - 10)).toChar.toString
Expand All @@ -238,7 +238,7 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
// e.g. "java.lang" -> Seq(/876/java/lang, /87/java/lang, /8/java/lang))
private val packageIndex: scala.collection.Map[String, scala.collection.Seq[Path]] = {
val index = collection.mutable.AnyRefMap[String, collection.mutable.ListBuffer[Path]]()
rootsForRelease.foreach(root => Files.walk(root).iterator().asScala.filter(Files.isDirectory(_)).foreach { p =>
rootsForRelease.foreach(root => Files.walk(root).iterator.asScala.filter(Files.isDirectory(_)).foreach { p =>
if (p.getNameCount > 1) {
val packageDotted = p.subpath(1, p.getNameCount).toString.replace('/', '.')
index.getOrElseUpdate(packageDotted, new collection.mutable.ListBuffer) += p
Expand All @@ -256,7 +256,7 @@ final class CtSymClassPath(ctSym: java.nio.file.Path, release: Int) extends Clas
if (inPackage == "") Nil
else {
val sigFiles = packageIndex.getOrElse(inPackage, Nil).iterator.flatMap(p =>
Files.list(p).iterator().asScala.filter(_.getFileName.toString.endsWith(".sig")))
Files.list(p).iterator.asScala.filter(_.getFileName.toString.endsWith(".sig")))
sigFiles.map(f => ClassFileEntryImpl(new PlainNioFile(f))).toVector
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/profile/Profiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private [profile] object RealProfiler {
val threadMx = ExtendedThreadMxBean.proxy
if (threadMx.isThreadCpuTimeSupported) threadMx.setThreadCpuTimeEnabled(true)
private val idGen = new AtomicInteger()
lazy val allPlugins = ServiceLoader.load(classOf[ProfilerPlugin]).iterator().asScala.toList
lazy val allPlugins = ServiceLoader.load(classOf[ProfilerPlugin]).iterator.asScala.toList
}

private [profile] class RealProfiler(reporter : ProfileReporter, val settings: Settings) extends Profiler with NotificationListener {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/transform/patmat/Logic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ trait Logic extends Debugging {

val pure = props map (p => rewriteEqualsToProp(p))

val eqAxioms = ImmutableArray.newBuilder[Prop]()
val eqAxioms = ImmutableArray.newBuilder[Prop]
@inline def addAxiom(p: Prop) = eqAxioms += p

debug.patmat("removeVarEq vars: "+ vars)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ trait Solving extends Logic {
val symForVar: Map[Int, Sym] = variableForSymbol.map(_.swap)

val relevantVars =
symForVar.keysIterator().map(math.abs).to(immutable.BitSet)
symForVar.keysIterator.map(math.abs).to(immutable.BitSet)

def lit(sym: Sym): Lit = Lit(variableForSymbol(sym))

Expand Down
10 changes: 5 additions & 5 deletions src/library/scala/Array.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ object Array {
implicit def toFactory[A : ClassTag](dummy: Array.type): Factory[A, Array[A]] =
new Factory[A, Array[A]] {
def fromSpecific(it: IterableOnce[A]): Array[A] = Array.from[A](it)
def newBuilder(): mutable.Builder[A, Array[A]] = Array.newBuilder[A]
def newBuilder: mutable.Builder[A, Array[A]] = Array.newBuilder[A]
}

/**
* Returns a new [[scala.collection.mutable.ArrayBuilder]].
*/
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T]()(t)
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T](t)

def from[A : ClassTag](it: IterableOnce[A]): Array[A] = {
val n = it.knownSize
if (n > -1) {
val elements = new Array[A](n)
val iterator = it.iterator()
val iterator = it.iterator
var i = 0
while (i < n) {
ScalaRunTime.array_update(elements, i, iterator.next())
i = i + 1
}
elements
} else {
val b = ArrayBuilder.make[A]()
val iterator = it.iterator()
val b = ArrayBuilder.make[A]
val iterator = it.iterator
while (iterator.hasNext)
b += iterator.next()
b.result()
Expand Down
2 changes: 1 addition & 1 deletion src/library/scala/Enumeration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
def toBitMask: Array[Long] = nnIds.toBitMask

override protected def fromSpecificIterable(coll: Iterable[Value]) = ValueSet.fromSpecific(coll)
override protected def newSpecificBuilder() = ValueSet.newBuilder
override protected def newSpecificBuilder = ValueSet.newBuilder

def map(f: Value => Value): ValueSet = fromSpecificIterable(new View.Map(toIterable, f))
def flatMap(f: Value => IterableOnce[Value]): ValueSet = fromSpecificIterable(new View.FlatMap(toIterable, f))
Expand Down
Loading

0 comments on commit e2094bf

Please sign in to comment.