Skip to content

Commit 81f82f2

Browse files
committed
Optimize redundant PRINT COLOR() settings.
The redundant settings are generated whenever there is more than one "COLOR()" inside the same print statement.
1 parent 09d06eb commit 81f82f2

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/compiler/peephole.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,22 @@ class peephole
506506
{
507507
current = i;
508508

509+
// Remove extra PRINT COLOR
510+
if(mtok(0, "TOK_NUM") && mword(1) && mtok(2, "TOK_BYTE_POKE") &&
511+
mcbyte(3, "PRINT_COLOR"))
512+
{
513+
// Remove if we are setting the same color as already set:
514+
if(val(1) == print_color)
515+
{
516+
del(3);
517+
del(2);
518+
del(1);
519+
del(0);
520+
i--;
521+
continue;
522+
}
523+
}
524+
509525
// Track current print color
510526
if(mtok(2, "TOK_BYTE_POKE") && mcbyte(3, "PRINT_COLOR"))
511527
{

0 commit comments

Comments
 (0)