The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8034

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
* use time.Since() instead of time.Now().Sub() for readability
* entry.Name is already string type, no need for fmt.Sprintf
* remove unneeded for-loop in getImages()

Signed-off-by: Tim Rots <tim.r...@protonmail.ch>
From b86ec451a5eda61ad35c52825fb826a4bb76966f Mon Sep 17 00:00:00 2001
From: Tim Rots <tim.r...@protonmail.ch>
Date: Thu, 15 Oct 2020 01:06:28 +0200
Subject: [PATCH] simplestreams.go: remove unneeded fmt.Sprintf and simplify
 getImages()

* use time.Since() instead of time.Now().Sub() for readbility
* entry.Name is already string type, no need for fmt.Sprintf
* remove unneeded for-loop in getImages()

Signed-off-by: Tim Rots <tim.r...@protonmail.ch>
---
 shared/simplestreams/simplestreams.go | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/shared/simplestreams/simplestreams.go 
b/shared/simplestreams/simplestreams.go
index fd420326a3..4d623f6eb2 100644
--- a/shared/simplestreams/simplestreams.go
+++ b/shared/simplestreams/simplestreams.go
@@ -82,7 +82,7 @@ func (s *SimpleStreams) readCache(path string) ([]byte, bool) 
{
                return nil, false
        }
 
-       expired := time.Now().Sub(fi.ModTime()) > s.cacheExpiry
+       expired := time.Since(fi.ModTime()) > s.cacheExpiry
 
        return body, expired
 }
@@ -248,7 +248,7 @@ func (s *SimpleStreams) applyAliases(images []api.Image) 
([]api.Image, []extende
 
                        for _, entry := range aliases {
                                // Short
-                               alias := addAlias(image.Type, 
image.Architecture, fmt.Sprintf("%s", entry.Name), image.Fingerprint)
+                               alias := addAlias(image.Type, 
image.Architecture, entry.Name, image.Fingerprint)
                                if alias != nil && architectureName == 
image.Architecture {
                                        image.Aliases = append(image.Aliases, 
*alias)
                                }
@@ -298,10 +298,7 @@ func (s *SimpleStreams) getImages() ([]api.Image, 
[]extendedAlias, error) {
                }
 
                streamImages, _ := products.ToLXD()
-
-               for _, image := range streamImages {
-                       images = append(images, image)
-               }
+               images = append(images, streamImages...)
        }
 
        // Setup the aliases
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to