Skip to content

Commit

Permalink
Removes unnecessary slice copies in statement adding
Browse files Browse the repository at this point in the history
  • Loading branch information
tomnomnom committed Sep 9, 2016
1 parent ec6e312 commit b8ebf80
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,18 @@ type statements []statement

// Add makes a copy of a statement and appends it to the list of statements
func (ss *statements) Add(s statement, new token) {
add := make(statement, len(s), len(s)+3)
copy(add, s)
add = append(add, token{"=", typEquals}, new, token{";", typSemi})
add := append(s, token{"=", typEquals}, new, token{";", typSemi})
*ss = append(*ss, add)
}

// AddFull adds a new statement to the list given the entire statement
func (ss *statements) AddFull(s statement) {
add := make(statement, len(s))
copy(add, s)
*ss = append(*ss, add)
*ss = append(*ss, s)
}

// AddMulti adds a whole other list of statements
func (ss *statements) AddMulti(l statements) {
add := make(statements, len(l))
copy(add, l)
*ss = append(*ss, add...)
*ss = append(*ss, l...)
}

// Len returns the number of statements for sort.Sort
Expand Down

0 comments on commit b8ebf80

Please sign in to comment.