Skip to content

more source tweaks to prepare for Dotty crossbuild #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object OldHashMap extends MapFactory[OldHashMap] {

def from[K, V](it: collection.IterableOnce[(K, V)]): OldHashMap[K, V] =
it match {
case hm: OldHashMap[K, V] => hm
case hm: OldHashMap[K @unchecked, V @unchecked] => hm
case _ => (newBuilder[K, V] ++= it).result()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sealed abstract class OldHashSet[A]
}

override def concat(that: collection.IterableOnce[A]): OldHashSet[A] = that match {
case that: OldHashSet[A] =>
case that: OldHashSet[A @unchecked] =>
val buffer = new Array[OldHashSet[A]](bufferSize(this.size + that.size))
nullToEmpty(union0(that, 0, buffer, 0))
case _ => super.concat(that)
Expand Down Expand Up @@ -167,7 +167,7 @@ object OldHashSet extends IterableFactory[OldHashSet] {

def from[A](it: collection.IterableOnce[A]): OldHashSet[A] =
it match {
case hs: OldHashSet[A] => hs
case hs: OldHashSet[A @unchecked] => hs
case _ => (newBuilder[A] ++= it).result()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ object CollectionConverters {
implicit class IterableIsParallelizable[A](private val coll: sc.Iterable[A]) extends AnyVal with sc.CustomParallelizable[A, ParIterable[A]] {
def seq = coll
override def par = coll match {
case coll: sc.Set[A] => new SetIsParallelizable(coll).par
case coll: sc.Set[A @unchecked] => new SetIsParallelizable(coll).par
case coll: sc.Map[_, _] => new MapIsParallelizable(coll).par.asInstanceOf[ParIterable[A]]
case coll: sci.Iterable[A] => new ImmutableIterableIsParallelizable(coll).par
case coll: scm.Iterable[A] => new MutableIterableIsParallelizable(coll).par
case coll: scm.Iterable[A @unchecked] => new MutableIterableIsParallelizable(coll).par
case _ => ParIterable.newCombiner[A].fromSequential(seq) // builds ParArray, same as for scm.Iterable
}
}
Expand All @@ -48,15 +48,15 @@ object CollectionConverters {
def seq = coll
override def par = coll match {
case coll: sci.Seq[A] => new ImmutableSeqIsParallelizable(coll).par
case coll: sci.Set[A] => new ImmutableSetIsParallelizable(coll).par
case coll: sci.Set[A @unchecked] => new ImmutableSetIsParallelizable(coll).par
case coll: sci.Map[_, _] => new ImmutableMapIsParallelizable(coll).par.asInstanceOf[immutable.ParIterable[A]]
case _ => immutable.ParIterable.newCombiner[A].fromSequential(seq) // builds ParVector
}
}

// Seq
implicit def seqIsParallelizable[A](coll: sc.Seq[A]): sc.Parallelizable[A, ParSeq[A]] = coll match {
case it: scm.Seq[A] => new MutableSeqIsParallelizable(it)
case it: scm.Seq[A @unchecked] => new MutableSeqIsParallelizable(it)
case it: sci.Seq[A] => new ImmutableSeqIsParallelizable(it)
case _ => throw new IllegalArgumentException("Unexpected type "+coll.getClass.getName+" - every scala.collection.Seq must be a scala.collection.mutable.Seq or scala.collection.immutable.Seq")
}
Expand Down Expand Up @@ -144,7 +144,7 @@ object CollectionConverters {
def seq = coll
override def par = coll match {
case coll: sci.Map[K, V] => new ImmutableMapIsParallelizable(coll).par
case coll: scm.Map[K, V] => new MutableMapIsParallelizable(coll).par
case coll: scm.Map[K @unchecked, V @unchecked] => new MutableMapIsParallelizable(coll).par
case _ => ParMap.newCombiner[K, V].fromSequential(seq)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ extends IterableOnce[T]
with CustomParallelizable[T, Repr]
with Parallel
with HasNewCombiner[T, Repr]
{
self =>
{ self =>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that Som reported this at scala/scala3#9515


def size: Int
def stringPrefix: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ import scala.collection.parallel.ParallelCollectionImplicits._
*/
trait ParSeqLike[+T, +CC[X] <: ParSeq[X], +Repr <: ParSeq[T], +Sequential <: scala.collection.Seq[T] with SeqOps[T, AnyConstr, Sequential]]
extends ParIterableLike[T, CC, Repr, Sequential]
with Equals {
self =>
with Equals { self =>

def length: Int
def apply(index: Int): T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ self =>
def split: Seq[IterableSplitter[(K, V)]] = if (remaining < 2) Seq(this) else triter match {
case t: TrieIterator[_] =>
val previousRemaining = remaining
val ((fst, fstlength), snd) = t.split
val ((fst: Iterator[(K, V) @unchecked], fstlength), snd: Iterator[(K, V) @unchecked]) = t.split
val sndlength = previousRemaining - fstlength
Seq(
new ParHashMapIterator(fst, fstlength),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
_loadFactor = lf
table = new Array[HashEntry[K, DefaultEntry[K, V]]](capacity(sizeForThreshold(_loadFactor, numelems)))
tableSize = 0
seedvalue = _seedvalue
this.seedvalue = _seedvalue
threshold = newThreshold(_loadFactor, table.length)
sizeMapInit(table.length)
def setSize(sz: Int) = tableSize = sz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
// TODO parallelize by keeping separate size maps and merging them
val tbl = new FlatHashTable[T] {
sizeMapInit(table.length)
seedvalue = ParHashSetCombiner.this.seedvalue
this.seedvalue = ParHashSetCombiner.this.seedvalue
for {
buffer <- buckets
if buffer ne null
Expand All @@ -184,7 +184,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
table = new Array[AnyRef](capacity(FlatHashTable.sizeForThreshold(numelems, _loadFactor)))
tableSize = 0
threshold = FlatHashTable.newThreshold(_loadFactor, table.length)
seedvalue = inseedvalue
this.seedvalue = inseedvalue
sizeMapInit(table.length)

override def toString = "AFHT(%s)".format(table.length)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ extends ParMap[K, V]
while (i < until) {
array(i) match {
case sn: SNode[_, _] => sz += 1
case in: INode[K, V] => sz += in.cachedSize(ctrie)
case in: INode[K @unchecked, V @unchecked] => sz += in.cachedSize(ctrie)
}
i += 1
}
Expand Down