Skip to content

Commit

Permalink
document testing of complexity vs. efficiency for reversing output
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebd committed Oct 9, 2023
1 parent 0b6753d commit 9ab2887
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions controller/rest/v1/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func GetLog(w http.ResponseWriter, r *http.Request, p httprouter.Params) {

logEvents, err := service.GetLog(config.LogDirectory, logFilename, maxLines)

// Reverse the slice - we want the most recent events first.
// Tests to see if this is slower than just iterating backwards when rendering
// showed that it was not. This is easier to read for maintainability.
slices.Reverse(logEvents)

util.RenderTextPlain(w, logEvents, err)
}

0 comments on commit 9ab2887

Please sign in to comment.