Skip to content

text/template: optimize Clone+Funcs+Execute sequence #38114

@rsc

Description

@rsc

In #31107 it came up that maybe most of the requested new functionality would be doable outside the package if it were possible to install new functions on a per-execution basis. One option is to add a new Execute that takes a second FuncMap, but I think we should consider not adding new API and instead make Clone+Funcs+Execute run faster.

It might be that all that's needed is making Clone make the actual template backing data copy-on-write. Then Clone is cheap. Then Funcs would copy only the map, or maybe even start a second map, also cheap. And Execute would be unchanged.

This issue is to think about whether this is possible to do without visible semantic changes, and if so, to do it.

/cc @bep @robpike @empijei

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions