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

Use @static check to simplify get_loaded_modules #80

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,13 @@ Returns a list of modules currently loaded by the system. On non-Linux platform
returns an empty list.
"""
function get_loaded_modules()
try
filter!(split.(readlines("/proc/modules"))) do (name, size, count, deps, state, addr)
return state == "Live"
end
catch e
if isa(e, SystemError)
return Vector{String}[]
end
rethrow(e)
@static if !Sys.islinux()
return Vector{String}[]
end

!isfile("/proc/modules") && return Vector{SubString{String}}[]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like one path returns Vector{String}[] and the other returns Vector{SubString{String}}[]. I think we can just safely return Vector{String}[] in both cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter!(split.(readlines("/proc/modules"))) do (name, size, count, deps, state, addr)
state == "Live"
giordano marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand Down