-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduced internal memory footprint and allocation count. This change
leads to an API-Change: ExecuteRW is being removed; instead it is replaced by a more general ExecuteWriter() which takes a Context and an io.Writer.
- Loading branch information
Showing
18 changed files
with
138 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
package pongo2 | ||
|
||
import ( | ||
"strings" | ||
"bytes" | ||
) | ||
|
||
// The root document | ||
type nodeDocument struct { | ||
Nodes []INode | ||
} | ||
|
||
func (doc *nodeDocument) Execute(ctx *ExecutionContext) (string, error) { | ||
collection := make([]string, 0, len(doc.Nodes)) | ||
func (doc *nodeDocument) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) error { | ||
for _, n := range doc.Nodes { | ||
buf, err := n.Execute(ctx) | ||
err := n.Execute(ctx, buffer) | ||
if err != nil { | ||
return "", err | ||
return err | ||
} | ||
collection = append(collection, buf) | ||
} | ||
return strings.Join(collection, ""), nil | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
package pongo2 | ||
|
||
import ( | ||
"bytes" | ||
) | ||
|
||
type nodeHTML struct { | ||
token *Token | ||
} | ||
|
||
func (n *nodeHTML) Execute(ctx *ExecutionContext) (string, error) { | ||
return n.token.Val, nil | ||
func (n *nodeHTML) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) error { | ||
buffer.WriteString(n.token.Val) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
package pongo2 | ||
|
||
import ( | ||
"strings" | ||
"bytes" | ||
) | ||
|
||
type NodeWrapper struct { | ||
Endtag string | ||
nodes []INode | ||
} | ||
|
||
func (wrapper *NodeWrapper) Execute(ctx *ExecutionContext) (string, error) { | ||
container := make([]string, 0, len(wrapper.nodes)) | ||
func (wrapper *NodeWrapper) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) error { | ||
for _, n := range wrapper.nodes { | ||
buf, err := n.Execute(ctx) | ||
err := n.Execute(ctx, buffer) | ||
if err != nil { | ||
return "", err | ||
return err | ||
} | ||
container = append(container, buf) | ||
} | ||
return strings.Join(container, ""), nil | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.