Skip to content

Commit c2f00b6

Browse files
authored
Merge pull request #668 from viperproject/joao-better-maps
Use asymptotically better `Map`
2 parents 3462c2d + cc751a7 commit c2f00b6

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/main/scala/decider/Z3ProverAPI.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import scala.collection.mutable
2222
import com.microsoft.z3._
2323
import viper.silicon.reporting.ExternalToolError
2424

25-
import scala.collection.immutable.ListMap
2625
import scala.jdk.CollectionConverters.MapHasAsJava
2726
import scala.util.Random
2827

@@ -339,7 +338,7 @@ class Z3ProverAPI(uniqueId: String,
339338
for (e <- statistics.getEntries()) {
340339
result.update(e.Key, e.getValueString)
341340
}
342-
ListMap.from(result)
341+
Map.from(result)
343342
}
344343

345344
def comment(str: String): Unit = {

src/main/scala/logger/SymbExLogger.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ object SymbExLogger {
221221
/**
222222
* stores the last SMT solver statistics to calculate the diff
223223
*/
224-
private var prevSmtStatistics: Map[String, String] = new Map()
224+
private var prevSmtStatistics: Map[String, String] = Map.empty
225225

226226
/** Add a new log for a method, function or predicate (member).
227227
*
@@ -304,13 +304,13 @@ object SymbExLogger {
304304
uidCounter = 0
305305
filePath = null
306306
logConfig = LogConfig.default()
307-
prevSmtStatistics = new Map()
307+
prevSmtStatistics = Map.empty
308308
}
309309

310310
def resetMemberList(): Unit = {
311311
memberList = Seq[SymbLog]()
312312
// or reset by calling it from Decider.reset
313-
prevSmtStatistics = new Map()
313+
prevSmtStatistics = Map.empty
314314
}
315315

316316
/**

src/main/scala/logger/writer/SymbExLogReportWriter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ object SymbExLogReportWriter {
158158
case _ =>
159159
}
160160

161-
var fields: Map[String, JsValue] = new Map()
161+
var fields: Map[String, JsValue] = Map.empty
162162

163163
fields = fields + ("id" -> JsNumber(record.id))
164164
fields = fields + ("kind" -> JsString(record.toTypeString))
@@ -188,7 +188,7 @@ object SymbExLogReportWriter {
188188
}
189189

190190
def toJSON(data: RecordData): Option[JsObject] = {
191-
var fields: Map[String, JsValue] = new Map()
191+
var fields: Map[String, JsValue] = Map.empty
192192

193193
data.refId.foreach(refId => fields = fields + ("refId" -> JsNumber(refId)))
194194

src/main/scala/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ package object silicon {
1414

1515
/* Immutable collections with a deterministic iteration order */
1616

17-
type Map[K, +V] = scala.collection.immutable.ListMap[K, V]
18-
val Map = scala.collection.immutable.ListMap
17+
type Map[K, +V] = scala.collection.immutable.TreeSeqMap[K, V]
18+
val Map = scala.collection.immutable.TreeSeqMap
1919

2020
@inline
2121
def toMap[K, V](it: Iterable[(K, V)]): Map[K, V] = Map.empty ++ it

0 commit comments

Comments
 (0)