From 454d44e85fb7e70d4f330da9054850f85a9482ff Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Wed, 2 Jan 2019 20:41:14 +0100 Subject: [PATCH] Optimize chains of assignments This allows optimizing, for example: integer a = 1; integer b = a; llOwnerSay((string)b); which wasn't done before. This case is prone to happen with inlined functions, e.g. using the result of an inlined function as a parameter to another. --- lslopt/lsldeadcode.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lslopt/lsldeadcode.py b/lslopt/lsldeadcode.py index e7abf62..360a1d2 100644 --- a/lslopt/lsldeadcode.py +++ b/lslopt/lsldeadcode.py @@ -318,6 +318,15 @@ class deadcode(object): node = sym['W'] nt = node.nt + + while nt == 'IDENT': + # Follow the chain of identifiers all the way to the original + if self.symtab[node.scope][node.name].get('W', False) is False: + return sym + sym = self.symtab[node.scope][node.name] + node = sym['W'] + nt = node.nt + if nt == 'CONST': tcurnode = curnode.t if tcurnode in ('integer', 'string', 'key'):