From ca2de3557a5ff60edb5e690f6113f29042c4f5e6 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Mon, 18 Sep 2023 16:40:20 +0530 Subject: [PATCH] [minor_change] Removed reverseString function and logic from model utils.go --- models/util.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/models/util.go b/models/util.go index 0612212..9b84a3c 100644 --- a/models/util.go +++ b/models/util.go @@ -99,27 +99,17 @@ func GetMORnPrefix(DistinguishedName string) string { if DistinguishedName != "" { bracketIndex := 0 rnIndex := 0 - reversedDistinguishedName := reverseString(DistinguishedName) - for i, v := range reversedDistinguishedName { - stringValue := string(v) - if stringValue == "]" { + for i := len(DistinguishedName) - 1; i >= 0; i-- { + if string(DistinguishedName[i]) == "]" { bracketIndex = bracketIndex + 1 - } else if stringValue == "[" { + } else if string(DistinguishedName[i]) == "[" { bracketIndex = bracketIndex - 1 - } else if stringValue == "/" && bracketIndex == 0 { + } else if string(DistinguishedName[i]) == "/" && bracketIndex == 0 { rnIndex = i break } } - return strings.Split(reverseString(reversedDistinguishedName[0:rnIndex]), "-")[0] + return strings.Split(string(DistinguishedName[rnIndex+1:]), "-")[0] } return DistinguishedName } - -func reverseString(s string) string { - reverse := "" - for i := len(s) - 1; i >= 0; i-- { - reverse += string(s[i]) - } - return reverse -}