【问题标题】:How to use compiled templates?如何使用编译好的模板?
【发布时间】:2014-06-25 09:50:41
【问题描述】:

我在 StringTemplate 页面上发现了一些关于模板编译的参考 (http://www.stringtemplate.org/api/org/stringtemplate/v4/compiler/Compiler.html)。 可以说,这些信息是宝石般的。

我找不到任何关于为什么以及如何在 ST4 中使用模板编译的描述/教程/示例。我想利用此功能,因为我怀疑它可能对性能有益。

任何指针?

【问题讨论】:

    标签: stringtemplate stringtemplate-4


    【解决方案1】:

    StringTemplate 4 实现始终使用该类。使用该库的代码无需手动启用、配置或直接与之交互。

    【讨论】:

    • 编译是为了提高性能还是为了其他目的?
    • StringTemplate 4 使用线性字节码解释器进行渲染,而不是基于 AST 的解释器(如使用的 StringTemplate 3)。由于没有不使用字节码解释器进行渲染的 StringTemplate 4 的替代实现,因此无法直接回答您的问题。但是,StringTemplate 4 的性能明显优于 StringTemplate 3,这种改进很可能(至少部分地)归因于这种差异。
    猜你喜欢
    • 2016-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多