Skip to content

Commit d0b18de

Browse files
committed
shuffle variable sorting around to attempt smaller compiled programs
1 parent 549c598 commit d0b18de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

codeGenCpu6502/src/prog8/codegen/cpu6502/VariableAllocator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ internal class VariableAllocator(private val symboltable: SymbolTable,
8888
// try to allocate any other interger variables into the zeropage until it is full.
8989
// TODO some form of intelligent priorization? most often used variables first? loopcounter vars first? ...?
9090
if(errors.noErrors()) {
91-
val sortedList = varsDontCare.sortedWith(compareBy<StStaticVariable> { it.scopedName.count { chr -> chr=='.'}}.thenBy { it.scopedName })
91+
val sortedList = varsDontCare.sortedByDescending { it.scopedName }
9292
for (variable in sortedList) {
9393
if(variable.dt in IntegerDatatypes) {
9494
if(zeropage.free.isEmpty()) {
@@ -125,6 +125,6 @@ internal class VariableAllocator(private val symboltable: SymbolTable,
125125
}
126126
}
127127
collect(st)
128-
return vars.sortedWith(compareBy<StStaticVariable> { it.scopedName }.thenBy { it.dt })
128+
return vars.sortedBy { it.dt }
129129
}
130130
}

0 commit comments

Comments
 (0)