Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove redundant len check #828

Merged
merged 1 commit into from
Oct 8, 2023
Merged

chore: remove redundant len check #828

merged 1 commit into from
Oct 8, 2023

Conversation

Juneezee
Copy link
Contributor

@Juneezee Juneezee commented Oct 7, 2023

From the Go specification (https://go.dev/ref/spec#For_range):

"3. If the map is nil, the number of iterations is 0."

len returns 0 if the map is nil (https://pkg.go.dev/builtin#len). Therefore, checking len(v) > 0 around a loop is unnecessary.

From the Go specification [1]:

  "3. If the map is nil, the number of iterations is 0."

`len` returns 0 if the map is nil [2]. Therefore, checking `len(v) > 0`
around a loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range
[2]: https://pkg.go.dev/builtin#len

Signed-off-by: Eng Zer Jun <[email protected]>
@abiosoft
Copy link
Owner

abiosoft commented Oct 8, 2023

Thanks :)

@abiosoft abiosoft merged commit 164ab2b into abiosoft:main Oct 8, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants