-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Littered throughout the CStr documentation are notes and hints that it should be eventually converted to using a pointer underneath the hood instead of a slice. This change will make CStr::from_ptr O(1) instead of O(n). Other constructors may still be O(n) because they have to check to ensure there is only one null terminator. If someone wants to try implementing this, it seems like a pretty simple change.
pub struct CStr {
inner: [c_char]
}
Proposed:
pub struct CStr {
inner: *const c_char
}
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.