Refactor C source to consolidate duplicate patterns#59
Open
Conversation
Add shared helper macros and functions to py_nif.h: - SAFE_FREE: null-safe free macro - GET_RESOURCE_OR_FAIL: resource validation macro - GET_BINARY_OR_FAIL: binary validation macro - CAN_ACQUIRE_GIL: GIL acquisition check - get_capsule_pointer_or_fail(): capsule validation helper - decode_etf_to_python(): ETF decoding helper Consolidate reader/writer functions in py_event_loop.c: - add_fd_watcher() consolidates nif_add_reader/nif_add_writer - remove_fd_watcher() consolidates nif_remove_reader/nif_remove_writer Refactor py_callback.c channel functions: - Replace PyCapsule_CheckExact patterns with helper - Replace ETF decoding blocks with decode_etf_to_python Apply macros to py_nif.c worker functions. Net reduction: ~37 lines (248 added, 285 removed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Net reduction: ~37 lines (248 added, 285 removed)