Skip to content

Commit

Permalink
Removed maximum buffered length, made sure buffer was on heap instead
Browse files Browse the repository at this point in the history
Knetic committed Oct 14, 2016
1 parent 89034fd commit 84f76a2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions TemplatedProject.go
Original file line number Diff line number Diff line change
@@ -22,8 +22,6 @@ const (
PLACEHOLDER_ITERATIVE_RECURSE_LN = "${{recurse}}\n"

archiveMarker = ".zip"

MAXIMUM_BUFFERED_LENGTH = 8192
)

/*
@@ -235,7 +233,6 @@ func (this *TemplatedProject) replaceFileContents(inPath, outPath string, mode o
*/
func (this *TemplatedProject) replaceStringParameters(input string, parameters map[string][]string) string {

var resultBuffer bytes.Buffer
var characters chan rune
var sequence, separator, parameterName string
var parameterValues []string
@@ -244,6 +241,8 @@ func (this *TemplatedProject) replaceStringParameters(input string, parameters m
characters = make(chan rune)
go readRunes(input, characters)

resultBuffer := bytes.NewBuffer([]byte{})

for {

sequence, exists = readUntil(PLACEHOLDER_OPEN, characters)
@@ -451,17 +450,18 @@ func readRunes(input string, results chan rune) {
*/
func readUntil(pattern string, characters chan rune) (string, bool) {

var buffer bytes.Buffer
var sequence string
var character rune
var index int
var done bool

buffer := bytes.NewBuffer([]byte{})

for {

character, done = <-characters

if !done || buffer.Len() > MAXIMUM_BUFFERED_LENGTH {
if !done {
return buffer.String(), false
}

0 comments on commit 84f76a2

Please sign in to comment.