| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
Scala 2.12.1 included optimizations to `HashMape.getOrElseUpdate`
to avoid recomputing the index in the hash table when adding an
the element.
However, this index could be stale if the callback added elements
to the map and triggered a resize.
This commit checks that the table is unchanged before reusing
the index, restoring the 2.12.0 behaviour.
|
|\ |
|
| |\
| | |
| | | |
SI-10164 BitSet.tail zigs where it zagged
|
| | |
| | |
| | |
| | |
| | | |
A cut/paste issue, an increment was held over from head,
which scans forward, to tail, which scans backward.
|
| |\ \
| | |/
| |/| |
SI-10177 Override lazy operations to preserve TrieMap's semantics
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Calling .iterator on a TrieMap gives a read-only snapshot. This then
extends to most inherited implementations written in terms of .iterator.
However, some inherited methods, such as .values, either defer the call
to .iterator or call it more than once. This results in subsequent
mutations to the original map being visible
I reviewed the inherited implementations from MapLike and found we
needed overrides of `values`, `keySet`, `filterKeys`, and `mapValues`.
Like `iterator`, these now create a read-only snapshot.
|
|\ \ \
| |/ /
|/| | |
|
| | |
| | |
| | |
| | |
| | | |
follows up on https://github.com/scala/scala/pull/5664;
fixes https://github.com/scala/scala-dev/issues/301
|
| | |
| | |
| | |
| | | |
Specifically, the `slice` and `take` methods.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
As they're reusable in 2.12.x with this change[1], it'd be useful
to make them reusable in 2.11.x.
[1] https://github.com/scala/scala/commit/6eaae1b969b68ed3dc65a40613a8168b09246256
With this change, not only are they reusable but also we can avoid
mutation of previously created arrays.
Behaviour(Problem):
Actual behaviour before this modification is as follows;
<ArrayBuilder>
```
scala> import scala.collection.mutable.ArrayBuilder
import scala.collection.mutable.ArrayBuilder
scala> val builder = new ArrayBuilder.ofInt
builder: scala.collection.mutable.ArrayBuilder.ofInt = ArrayBuilder.ofInt
scala> builder ++= Vector.range(1, 17)
res0: builder.type = ArrayBuilder.ofInt
scala> val arr = builder.result()
arr: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
scala> builder.clear()
scala> builder += 100
res2: builder.type = ArrayBuilder.ofInt
scala> val arr2 = builder.result()
arr2: Array[Int] = Array(100)
scala> arr
res3: Array[Int] = Array(100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
// arr should be Array(1, .., 16) but was unexpectedly mutated by `+=` operation
```
`arr` was mutated as follows;
1. `result` & `clear`
- `arr = elems`
- `size = 0`
2. `+=(100)`
- `ensureSize(0 + 1)`
=> `capacity < size || capacity == 0` is `false` as `capacity == 16`
and `size == 1`
- `elems(0) = 100` this is where `arr(0) = 100` was done because we
did not reallocate a new array for `elems` when calling `ensureSize`,
which should have happened.
- `size = 1`
3. `result`
- `mkArray(1)` gives us `arr2 = Array(100)`
<WrappedArrayBuilder>
We can observe almost the same mutation behaviour of ArrayBuilder.
```
scala> import scala.collection.mutable.WrappedArray
import scala.collection.mutable.WrappedArray
scala> import scala.collection.mutable.WrappedArrayBuilder
import scala.collection.mutable.WrappedArrayBuilder
scala> import scala.reflect.ClassTag
import scala.reflect.ClassTag
scala> val builder = new WrappedArrayBuilder(ClassTag.Int)
builder: scala.collection.mutable.WrappedArrayBuilder[Int] = scala.collection.mutable.WrappedArrayBuilder@56cbfb61
scala> builder ++= Vector.range(1, 17)
res0: builder.type = scala.collection.mutable.WrappedArrayBuilder@56cbfb61
scala> builder.result()
res1: scala.collection.mutable.WrappedArray[Int] = WrappedArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
scala> builder.clear()
scala> builder += 100
res3: builder.type = scala.collection.mutable.WrappedArrayBuilder@56cbfb61
scala> res1
res4: scala.collection.mutable.WrappedArray[Int] = WrappedArray(100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
scala> builder.result()
res5: scala.collection.mutable.WrappedArray[Int] = WrappedArray(100)
```
Solution:
We should reset `capacity` to `0` when calling `result` so that
`ensureSize(1)` calls `resize(16)`, which satisfies the property of Builder
reusability. Besides mutation of previously created arrays does not happen.
|
| |/
|/| |
|
| |
| |
| |
| | |
added missing overrides for TreeMapView
|
| |
| |
| |
| |
| |
| | |
Also suffered from the negative `from` bug.
Prefer `math.max` to avoid `RichInt`.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
merge/2.11.x-to-2.12.x-20161220
Conflicts:
bincompat-backward.whitelist.conf
build.xml
src/compiler/scala/tools/nsc/typechecker/Typers.scala
src/library/scala/collection/immutable/NumericRange.scala
|
| |
| |
| | |
SI-10086 NumericRange.min|max with custom Integral
|
| | |
|
| | |
|
|\ \
| | |
| | | |
SI-9888. Prevent OOM on ParRange. Improve toString.
|
| | | |
|
|\ \ \
| | |/
| |/| |
|
| | |
| | |
| | |
| | |
| | | |
Even if no elements fail the predicate (so that the trailing
iterator is empty).
|
| |\ \
| | | |
| | | | |
SI 9766 - allow ++ on empty ConcatIterator
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | | |
Rewrite TraversableLike.stringPrefix not to blow up code size in Scala.js.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The commit 30876fe2dd8cbe657a6cad6b11bbc34f10c29b36 changed
`TraversableLike.stringPrefix` to report nicer results for inner
classes and method-local classes. The changes included calls to
`String.split()`, `Character.isDigit()` and `Character.isUpperCase()`.
This was particularly bad for Scala.js, because those methods
bring with them huge parts of the JDK (the `java.util.regex.*`
implementation on the one hand, and the Unicode database on the
other hand), which increased generated code size by 6 KB after
minimification and gzip for an application that does not otherwise
use those methods. This sudden increase is tracked in the Scala.js
bug tracker at https://github.com/scala-js/scala-js/issues/2591.
This commit rewrites `TraversableLike.stringPrefix` in a very
imperative way, without resorting to those methods. The behavior
is (mostly) preserved. There can be different results when
`getClass().getName()` contains non-ASCII lowercase letters and/or
digits. Those will now be recognized as user-defined instead of
likely compiler-synthesized (which is a progression). There still
are false positives for ASCII lowercase letters, which cause the
`stringPrefix` to be empty (as before).
Since the new implementation is imperative anyway, at least I made
it not allocate anything but the result `String` in the common
case where the result does not contain any `.`.
|
|\ \ \ \ \ |
|
| |/ / / / |
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This follows the Scaladoc, and makes
```
"abcdef".indexOf('c', -1)
```
work like
```
"abcdef".toVector.indexOf('c', -1)
```
|
| | | | |
|
| |_|/
|/| |
| | |
| | |
| | |
| | | |
Rather than putting the code of a trait method body into a static method,
leave it in the default method. The static method (needed as the target
of the super calls) now uses `invokespecial` to exactly call that method.
|
|\ \ \
| | | |
| | | | |
SI-8434 Make generic Set operations build the same kind of Set
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When building from a `Set` implementation that was statically seen as
a `collection.GenSet` or `collection.Set`, we used to build a default
`Set` implementation determined by `GenSetFactory.setCanBuildFrom`.
This change modifies `setCanBuildFrom` to determine the correct
implementation at runtime by asking the source `Set`’s companion object
for the `Builder`.
Tests are in `NewBuilderTest.mapPreservesCollectionType`, including lots
of disabled tests for which I believe there is no solution under the
current collection library design.
`Map` suffers from the same problem as `Set`. This *can* be fixed in the
same way as for `Set` with some non-trivial changes (see the note in
`NewBuilderTest`), so it is probably best left for Scala 2.13.
|
|\ \ \ \
| | | | |
| | | | | |
SI-9019 TraversableLike stringPrefix broken for inner classes
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This version preserves outer class and object names but discards
any part of the name after a `$` that does not start with an upper-case
letter. When an integer literal occurs after a `$`, the prefix up to
that point is dropped so that classes defined within methods appear as
top-level.
|
|\ \ \ \ \
| |_|/ / /
|/| | | | |
SI-6881 Detect reference equality when comparing streams
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`==` already covers this case. We override `equals` in `Stream` to do
the same when `equals` is called directly. This takes care of identical
streams.
To support short-circuiting equality checks on elements prepended to
identical streams we also override `sameElements` in `Cons` to treat
the case where both sides are `Cons` separately.
Tests in StreamTest.test_reference_equality.
|
|/ / /
| | |
| | |
| | | |
This exposes a new API to the BufferedIterator trait. It will return the next element of an iterator as an Option. The return will be Some(value) if there is a next value, and None if there is not a next element.
|
|\| | |
|
| |/
| |
| |
| |
| |
| |
| |
| | |
The kv field of scala.collection.immutable.HashMap.HashMap1 can be null. This
commit corrects the behavior of updated0 (which is on call path for merged) to
work in such cases, instead of throwing NPE.
Commit contains regression test.
|
| |
| |
| |
| |
| |
| |
| | |
We delegate `String`'s extension methods `toInt`, `toFloat`, etc to corresponding
methods in the Java standard library. These differ in the way they handle
whitespace in the original string.
This commit documents and tests the current behaviour.
|
|\ \
| | |
| | | |
SI-9382 Privatize enhanced x in Tuple2Zipped.Ops
|
| | |
| | |
| | |
| | |
| | | |
Consolated JUnit tests and heeded comment about private def and
code beauty.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
This sets the key field in the hash table entry to its default value
when an entry is deleted, so as not to unexpectedly retain an object
reference, leading to a memory leak.
Also includes incidental changes to the slot location algorithm that
reduce the number of deleted entries.
|
| |
| |
| |
| |
| |
| |
| | |
Test classes not ending in "Test" are not executed in sbt. IntelliJ
runs them.
After this patch: 803 tests executed both in sbt and junit.
|
|\ \
| | |
| | | |
Improve performance and behavior of ListMap and ListSet
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Makes the immutable `ListMap` and `ListSet` collections more alike one another, both in their semantics and in their performance.
In terms of semantics, makes the `ListSet` iterator return the elements in their insertion order, as `ListMap` already does. While, as mentioned in SI-8985, `ListMap` and `ListSet` doesn't seem to make any guarantees in terms of iteration order, I believe users expect `ListSet` and `ListMap` to behave in the same way, particularly when they are implemented in the exact same way.
In terms of performance, `ListSet` has a custom builder that avoids creation in O(N^2) time. However, this significantly reduces its performance in the creation of small sets, as its requires the instantiation and usage of an auxilliary HashSet. As `ListMap` and `ListSet` are only suitable for small sizes do to their performance characteristics, the builder is removed, the default `SetBuilder` being used instead.
|
|/ / |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Implicit conversions are now in package convert as ImplicitConversions,
ImplicitConversionsToScala and ImplicitConversionsToJava.
Deprecated WrapAsJava, WrapAsScala and the values in package object.
Improve documentation.
|
|\|
| |
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
src/library/scala/collection/Iterator.scala
|
`-- trivial conflicts only. Parens were added to the
next() calls in 2.12.x, while in the meantime
`{Concat,Join}Iterator` were optimized in 2.11.x
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
These iterator implementations are used to concatenate two (JoinIterator)
or more (ConcatIterator) other iterators with `++`. They used to perform
many unnecessary calls to the child iterators’ `hasNext` methods.
This improved state machine-based implementation reduces that number to
the bare minimum, i.e. iterating over concatenated iterators with
`foreach` calls the children's `hasNext` methods a total of (number of
children) + (number of elements) times, the same as when iterating over
all children separately.
|