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

Unneeded uniq() #646

Open
x-yuri opened this issue Dec 7, 2022 · 0 comments
Open

Unneeded uniq() #646

x-yuri opened this issue Dec 7, 2022 · 0 comments

Comments

@x-yuri
Copy link

x-yuri commented Dec 7, 2022

This is apparently a minor issue, but I just noticed and decided to report it:

let l:servers = []
for l:ft in keys(l:settings)
for l:v in l:settings[l:ft]
if index(l:servers, l:v.command) ==# -1
call add(l:servers, l:v.command)
endif
endfor
endfor
for l:server in uniq(sort(l:servers))

First you create a unique list of commands, then pass it to uniq() which makes no difference. Unless I'm missing something.

On a side note I thought if it could be done in a more compact way, and here's what I ended up with:

let Flatten = {d -> reduce(values(d), {r, i -> extend(r, i)})}
let l:servers = mapnew(l:settings, 'mapnew(v:val, "v:val.command")')
let l:servers = uniq(sort(Flatten(l:servers)))

Not that it's necessarily better.

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

No branches or pull requests

1 participant