alficles commented on a change in pull request #4419: ORT Speed Improvements
URL: https://github.com/apache/trafficcontrol/pull/4419#discussion_r382256966
 
 

 ##########
 File path: traffic_ops/ort/atstccfg/toreq/caching.go
 ##########
 @@ -177,3 +215,65 @@ func GetCookiesFromFile(tempDir string, cacheFileMaxAge 
time.Duration) (string,
        }
        return string(bts), nil
 }
+
+// DSSExtension is the file extension for the format read and written by 
DSSEncode and DSSDecode.
+const DSSExtension = ".csv"
+
+// DSSEncode is an EncodeFunc optimized for Delivery Service Servers.
+// If iObj is not a *[]tc.DeliveryServiceServer it immediately returns an 
error.
+func DSSEncode(w io.Writer, iObj interface{}) error {
+       // Please don't change this to use encoding/csv unless you benchmark 
and prove it's at least as fast. DSS is massive, and performance is important.
+       obj, ok := iObj.(*[]tc.DeliveryServiceServer)
+       if !ok {
+               return fmt.Errorf("object is '%T' must be a 
*[]tc.DeliveryServiceServer\n", iObj)
+       }
+       for _, dss := range *obj {
+               if dss.DeliveryService == nil || dss.Server == nil {
+                       continue // TODO warn?
+               }
+               if _, err := io.WriteString(w, 
strconv.Itoa(*dss.DeliveryService)+`,`+strconv.Itoa(*dss.Server)+"\n"); err != 
nil {
 
 Review comment:
   Would this be faster with multiple writes instead of string concatenation?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to