Skip to content

Replace runtime cfg!(target_os = ... with macros for compile-time #4587

@n0toose

Description

@n0toose

Hi, I spent a bit of time looking through Anki's source code and realized that there were many excerpts that check for the operating system that Anki is being currently run on, e.g.:

if cfg!(target_os = "macos") {

In many cases, like the one linked above, such checks can be done at compile-time and don't have to take place during the runtime, for example see here:

#[cfg(target_os = "macos")]

There are a couple of cases where this turns up: https://github.com/search?q=repo%3Aankitects%2Fanki+cfg%21%28target_&type=code

The if-else cases can be substituted e.g. with #[cfg(not(target_os = "macos"))] or similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions