From d0b18dec8e3e3d9e7e4545320f4020578e8e5dec Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 12 Feb 2023 17:34:33 +0100 Subject: [PATCH] shuffle variable sorting around to attempt smaller compiled programs --- codeGenCpu6502/src/prog8/codegen/cpu6502/VariableAllocator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/VariableAllocator.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/VariableAllocator.kt index 9d67a2d3b..862c0a6b5 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/VariableAllocator.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/VariableAllocator.kt @@ -88,7 +88,7 @@ internal class VariableAllocator(private val symboltable: SymbolTable, // try to allocate any other interger variables into the zeropage until it is full. // TODO some form of intelligent priorization? most often used variables first? loopcounter vars first? ...? if(errors.noErrors()) { - val sortedList = varsDontCare.sortedWith(compareBy { it.scopedName.count { chr -> chr=='.'}}.thenBy { it.scopedName }) + val sortedList = varsDontCare.sortedByDescending { it.scopedName } for (variable in sortedList) { if(variable.dt in IntegerDatatypes) { if(zeropage.free.isEmpty()) { @@ -125,6 +125,6 @@ internal class VariableAllocator(private val symboltable: SymbolTable, } } collect(st) - return vars.sortedWith(compareBy { it.scopedName }.thenBy { it.dt }) + return vars.sortedBy { it.dt } } }