[lxc-devel] [lxd/master] lxd/types: use parallel assignment for val swap

Quasilyte on Github lxc-bot at linuxcontainers.org
Fri Jan 11 16:15:18 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 365 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190111/8ea4d814/attachment.bin>
-------------- next part --------------
From d123225e7db5c86c3088a98588de55ba97558daa Mon Sep 17 00:00:00 2001
From: "Iskander (Alex) Sharipov" <quasilyte at gmail.com>
Date: Fri, 11 Jan 2019 19:15:03 +0300
Subject: [PATCH] lxd/types: use parallel assignment for val swap

Change value swap through tmp variable to a parallel assignment.
---
 lxd/types/devices_sort.go | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lxd/types/devices_sort.go b/lxd/types/devices_sort.go
index 359431ee42..938b240d09 100644
--- a/lxd/types/devices_sort.go
+++ b/lxd/types/devices_sort.go
@@ -32,9 +32,7 @@ func (devices sortableDevices) Less(i, j int) bool {
 }
 
 func (devices sortableDevices) Swap(i, j int) {
-	tmp := devices[i]
-	devices[i] = devices[j]
-	devices[j] = tmp
+	devices[i], devices[j] = devices[j], devices[i]
 }
 
 func (devices sortableDevices) Names() []string {


More information about the lxc-devel mailing list