mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	refactor: use slices.Equal to simplify code (#4764)
- **PR Description** In the Go 1.21 standard library, a new function has been introduced that enhances code conciseness and readability. It can be find [here](https://pkg.go.dev/slices@go1.21.1#Equal).
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| package git_commands | ||||
|  | ||||
| import ( | ||||
| 	"slices" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
|  | ||||
| @@ -43,7 +44,7 @@ func (self *MainBranches) Get() []string { | ||||
|  | ||||
| 	configuredMainBranches := self.c.UserConfig().Git.MainBranches | ||||
|  | ||||
| 	if self.existingMainBranches == nil || !utils.EqualSlices(self.previousMainBranches, configuredMainBranches) { | ||||
| 	if self.existingMainBranches == nil || !slices.Equal(self.previousMainBranches, configuredMainBranches) { | ||||
| 		self.existingMainBranches = self.determineMainBranches(configuredMainBranches) | ||||
| 		self.previousMainBranches = configuredMainBranches | ||||
| 	} | ||||
|   | ||||
| @@ -179,18 +179,3 @@ func Shift[T any](slice []T) (T, []T) { | ||||
| 	slice = slice[1:] | ||||
| 	return value, slice | ||||
| } | ||||
|  | ||||
| // Compares two slices for equality | ||||
| func EqualSlices[T comparable](slice1 []T, slice2 []T) bool { | ||||
| 	if len(slice1) != len(slice2) { | ||||
| 		return false | ||||
| 	} | ||||
|  | ||||
| 	for i := range slice1 { | ||||
| 		if slice1[i] != slice2[i] { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return true | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user