Skip to content

refactor: use vim.loop.os_uname() for is_arm #513

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

Merged
merged 1 commit into from
Jul 16, 2025

Conversation

samirettali
Copy link
Contributor

@samirettali samirettali commented Jul 12, 2025

While configuring lazy loading in my config I noticed that copilot.lua took ~60ms on average to load, a lot of which is because of io.popen() so I changed the is_arm() function to use the .machine field of vim.loop.os_uname() which was already called.

I checked the neovim source code and i think it can still be simplified but I'm not entirely sure, this is the piece of code i found:

--- @param s 'x86_64'|'arm64'
--- @return boolean
function M.is_arch(s)
  if not (s == 'x86_64' or s == 'arm64') then
    error('unknown architecture: ' .. tostring(s))
  end
  return s == architecture
end

Load time with this change is ~13ms on average, I only tested it on an M1 Macbook.

@AntoineGS
Copy link
Collaborator

nice performance improvment :P

@AntoineGS AntoineGS merged commit 14bf786 into zbirenbaum:master Jul 16, 2025
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.

2 participants