zrhoffman commented on a change in pull request #5084:
URL: https://github.com/apache/trafficcontrol/pull/5084#discussion_r497730046
##########
File path: traffic_ops/traffic_ops_golang/federations/ds.go
##########
@@ -46,7 +45,7 @@ func PostDSes(w http.ResponseWriter, r *http.Request) {
fedID := inf.IntParams["id"]
fedName, ok, err := getFedNameByID(inf.Tx.Tx, fedID)
if err != nil {
- api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, errors.New("getting federation cname from ID '"+string(fedID)+"':
"+err.Error()))
+ api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, errors.New("getting federation cname from ID '"+strconv.Itoa(fedID)+"':
"+err.Error()))
Review comment:
I too agree that formatted strings are nicer-looking than concatenation
(or joining) and prefer it when performance is not an issue. Benchmarking
locally, when making an error 100000000 times,
```go
errors.New("getting federation cname from ID '"+strconv.Itoa(fedID)+"':
"+err.Error())
```
takes around 9 seconds, and
```go
fmt.Errorf("getting federation cname from ID %d: %s", fedID, err.Error())
```
takes around 22 seconds. IMO a ~2x slowdown for this single line is
acceptable in this case, especially since that factor will not change based on
the value of the `fedId` or the message of `err`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]