diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-05-09 15:27:01 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-05-09 15:27:01 +0200 |
commit | 7bac372a85e5a06ec147ec648caab76df704d8dc (patch) | |
tree | 18e4b7aa8eb345d67ed796fe3661ec39350cb2e2 | |
parent | d32459b8ca1164a1fde801397396218a216b7670 (diff) | |
parent | b154269b0e7447cfbf7fdb73c8c4efcdca545b11 (diff) | |
download | scala-7bac372a85e5a06ec147ec648caab76df704d8dc.tar.gz scala-7bac372a85e5a06ec147ec648caab76df704d8dc.tar.bz2 scala-7bac372a85e5a06ec147ec648caab76df704d8dc.zip |
Merge pull request #3727 from retronym/ticket/8531
SI-8531 Better space efficiency for patmat analysis
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/patmat/Solving.scala | 8 | ||||
-rw-r--r-- | test/files/pos/t8531/MyEnum.java | 5 | ||||
-rw-r--r-- | test/files/pos/t8531/Test.scala | 24 |
3 files changed, 35 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala b/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala index 1902606d86..31b1ffa912 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/Solving.scala @@ -29,8 +29,12 @@ trait Solving extends Logic { type Clause = collection.Set[Lit] // a clause is a disjunction of distinct literals def clause(l: Lit*): Clause = ( - // neg/t7020.scala changes output 1% of the time, the non-determinism is quelled with this linked set - mutable.LinkedHashSet(l: _*) + if (l.lengthCompare(1) <= 0) { + l.toSet // SI-8531 Avoid LinkedHashSet's bulk for 0 and 1 element clauses + } else { + // neg/t7020.scala changes output 1% of the time, the non-determinism is quelled with this linked set + mutable.LinkedHashSet(l: _*) + } ) type Lit diff --git a/test/files/pos/t8531/MyEnum.java b/test/files/pos/t8531/MyEnum.java new file mode 100644 index 0000000000..06cc128a79 --- /dev/null +++ b/test/files/pos/t8531/MyEnum.java @@ -0,0 +1,5 @@ + +package foobar; +public enum MyEnum { +A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31, A32, A33, A34, A35, A36, A37, A38, A39, A40, A41, A42, A43, A44, A45, A46, A47, A48, A49, A50, A51, A52, A53, A54, A55, A56, A57, A58, A59, A60, A61, A62, A63, A64, A65, A66, A67, A68, A69, A70, A71, A72, A73, A74, A75, A76, A77, A78, A79, A80, A81, A82, A83, A84, A85, A86, A87, A88, A89, A90, A91, A92, A93, A94, A95, A96, A97, A98, A99, A100, A101, A102, A103, A104, A105, A106, A107, A108, A109, A110, A111, A112, A113, A114, A115, A116, A117, A118, A119, A120, A121, A122, A123, A124, A125, A126, A127, A128, A129, A130, A131, A132, A133, A134, A135, A136, A137, A138, A139, A140, A141, A142, A143, A144, A145, A146, A147, A148, A149, A150, A151, A152, A153, A154, A155, A156, A157, A158, A159, A160, A161, A162, A163, A164, A165, A166, A167, A168, A169, A170, A171, A172, A173, A174, A175, A176, A177, A178, A179, A180, A181, A182, A183, A184, A185, A186, A187, A188, A189, A190, A191, A192, A193; +} diff --git a/test/files/pos/t8531/Test.scala b/test/files/pos/t8531/Test.scala new file mode 100644 index 0000000000..59861435a6 --- /dev/null +++ b/test/files/pos/t8531/Test.scala @@ -0,0 +1,24 @@ +package test + +// takes > 50s and > 800M heap to compile under 2.11.0 +import foobar._ +class `SI-8531` { + //https://issues.scala-lang.org/browse/SI-8531 + + import MyEnum._ + def foo(e1: MyEnum, e2: MyEnum) = (e1, e2) match { + case (A1, x) => "a1" + case (x, A1) => "a1" + case (A2, x) => "a2" + case (x, A2) => "a2" + case (A3, x) => "a3" + case (x, A3) => "a3" + case (A4, x) => "a4" + case (x, A4) => "a4" + case (A5, x) => "a5" + case (x, A5) => "a5" + case (A6, x) => "a6" + case (x, A6) => "a6" + case (a, b) => "ab" + } +} |