nielsAD / lape

Scripting engine with Pascal-like syntax for FPC and Delphi
119 stars 28 forks source link

Compile time optimization #157

Closed ollydev closed 3 years ago

ollydev commented 3 years ago

Compiling SRL went from 450ms to 280ms. I think the only other related optimization worth doing in the future would be not compiling method statement list if the method is never used.

Changes:

TLapeDeclCollection is now an abstract class.

TLapeDeclarationList uses TLapeDeclCollection_Dictionary by default. There remains TLapeDeclCollection_List for when normal indexing is required which is currently only TLapeType_OverloadedMethod.


Added TLapeUniqueDictionary which is a dictionary where each bucket can only have one value. TLapeCompiler.getBaseType(Name: lpString) and Lape_IsKeyword now use this.


Optimized TLapeCompiler.getConstant and usage of it. TLapeParser.Identify Alpha() no longer appends character by character. getTokString is now called once at the end. Removed some compiling hints.