Skip to content

Commit

Permalink
metadata returns a reference to avoid temps
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsutherland committed Mar 1, 2019
1 parent 608a405 commit 6a3abb1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func (d download) needsSlugWhenGivenTrackOrTeam() error {
return nil
}

func (d downloadPayload) metadata() ws.ExerciseMetadata {
return ws.ExerciseMetadata{
func (d downloadPayload) metadata() *ws.ExerciseMetadata {
return &ws.ExerciseMetadata{
AutoApprove: d.Solution.Exercise.AutoApprove,
Track: d.Solution.Exercise.Track.ID,
Team: d.Solution.Team.Slug,
Expand All @@ -211,8 +211,7 @@ func (d downloadPayload) metadata() ws.ExerciseMetadata {
}

func (d download) exercise() ws.Exercise {
metadata := d.metadata()
return metadata.Exercise(d.workspace)
return d.metadata().Exercise(d.workspace)
}

// requestFile requests a Solution file from the API, returning an HTTP response.
Expand Down Expand Up @@ -257,8 +256,7 @@ func newDownloadWriter(dl *download) *downloadWriter {

// writeMetadata writes the exercise metadata.
func (w downloadWriter) writeMetadata() error {
metadata := w.download.metadata()
return metadata.Write(w.destination())
return w.download.metadata().Write(w.destination())
}

// writeSolutionFiles attempts to write each file from the downloaded solution.
Expand Down

0 comments on commit 6a3abb1

Please sign in to comment.