mirror of https://github.com/KarolS/millfork.git
Minor optimizations
This commit is contained in:
parent
ee47ccef5a
commit
d8c11a9c50
|
@ -160,11 +160,6 @@ case class CpuStatus(a: Status[Int] = UnknownStatus,
|
|||
}
|
||||
|
||||
def hasSet(state: State.Value): Boolean = state match {
|
||||
case State.A => false
|
||||
case State.AH => false
|
||||
case State.X => false
|
||||
case State.Y => false
|
||||
case State.IZ => false
|
||||
case State.Z => z.contains(true)
|
||||
case State.N => n.contains(true)
|
||||
case State.C => c.contains(true)
|
||||
|
|
|
@ -21,12 +21,16 @@ case class FlowInfo(holder: FlowHolder, index: Int, _labelUseCountMap: () => Opt
|
|||
lazy val importanceAfter: CpuImportance = holder.importanceAfter(index)
|
||||
lazy val labelUseCountMap: Option[Map[String, Int]] = _labelUseCountMap()
|
||||
|
||||
@inline
|
||||
def hasClear(state: State.Value): Boolean = statusBefore.hasClear(state)
|
||||
|
||||
@inline
|
||||
def hasSet(state: State.Value): Boolean = statusBefore.hasSet(state)
|
||||
|
||||
@inline
|
||||
def isUnimportant(state: State.Value): Boolean = importanceAfter.isUnimportant(state)
|
||||
|
||||
@inline
|
||||
def labelUseCount(label: String): Int = labelUseCountMap.map(_.getOrElse(label, 0)).getOrElse(-1)
|
||||
|
||||
override def toString: String = holder.toString(index)
|
||||
|
|
|
@ -295,18 +295,20 @@ class Environment(val parent: Option[Environment], val prefix: String, val cpuFa
|
|||
|
||||
private def removeVariableImpl(str: String): Unit = {
|
||||
def extractThingName(fullName: String): String = {
|
||||
var result = fullName.takeWhile(_ != '.')
|
||||
if (result.length == fullName.length) return result
|
||||
val suffix = fullName.drop(result.length)
|
||||
val ix = fullName.indexOf('.')
|
||||
if (ix < 0) return fullName
|
||||
var result = fullName.substring(0, ix)
|
||||
val suffix = fullName.substring(ix)
|
||||
if (suffix == ".return" || suffix.startsWith(".return.")) {
|
||||
result += ".return"
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
val strWithoutPrefix = str.stripPrefix(prefix)
|
||||
val toRemove = things.keys.filter { n =>
|
||||
val baseName = extractThingName(n)
|
||||
baseName == str || baseName == str.stripPrefix(prefix)
|
||||
baseName == str || baseName == strWithoutPrefix
|
||||
}.toSet
|
||||
removedThings ++= toRemove.map(_.stripPrefix(prefix))
|
||||
things --= toRemove
|
||||
|
|
Loading…
Reference in New Issue