Skip to content

Commit

Permalink
Merge pull request #250 from ichiban/reuse-underlying-string-for-char…
Browse files Browse the repository at this point in the history
…List-Arg

reuse the underlying string when charList.Arg(0) is called
  • Loading branch information
ichiban authored Sep 19, 2022
2 parents 9a6eb5a + ad36045 commit c0d1918
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions engine/compound.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,12 @@ func (c charList) Arity() int {
}

func (c charList) Arg(n int) Term {
_, i := utf8.DecodeRuneInString(string(c))
var t Term
switch n {
case 0:
r, _ := utf8.DecodeRuneInString(string(c))
t = Atom(r)
t = Atom(c[:i])
case 1:
_, i := utf8.DecodeRuneInString(string(c))
if i == len(c) {
t = Atom("[]")
} else {
Expand Down

0 comments on commit c0d1918

Please sign in to comment.