Skip to content

Swapping pointer values that should never be null with NonNull variants. #686

@ErisianArchitect

Description

@ErisianArchitect

I was reading some code, and I noticed that PointerValue wraps Value, which wraps LLVMValueRef, which is a type alias for *mut llvm_sys::LLVMValue. So I was thinking that perhaps it would make sense to instead use NonNull<LLVMValue> (or other relevant pointer type) in these places where non-nullable pointers are used.

Then these types could have repr(transparent), which would guarantee that they have the niche optimization that NonNull has, allowing T to be the same size as Option<T>, which is a very useful memory optimization.

I'm going to get started on this PR today. I just wanted to make an issue for it since there's a rule that pull requests need to be related to an issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions