This PR makes a few small changes to improve the maintainability of the code.
The individual changes are small, but because some of these patterns were repeated many times in the code, quite a few places in the code were modified.
The changes are:
Use the compiler-checked static_cast and reinterpret_casts instead of C-style casts.
Removed the non-standard #pragma once; standardized header guards (#ifndef ...) are enough.
Include the C++ version of C headers (e.g. cstdbool instead of bool.h)
Move the cleanup of AdbcError inside adbc_error_to_nif_error which allowed it to be removed everywhere this function is called.
Ensure objects we'll use are always defined (in some cases objects were only declared before they were used, causing compiler warnings).
Remove memset where it is not necessary now that the contents of NifRes are not separately allocated.
As added benefit, the resulting code is roughly a hundred lines shorter (without sacrificing readability) :blush: .
If you want to view one of these changes separate from the others (e.g. to better understand it): The individual commits have descriptions and each only contain a single change.
This PR makes a few small changes to improve the maintainability of the code. The individual changes are small, but because some of these patterns were repeated many times in the code, quite a few places in the code were modified.
The changes are:
static_cast
andreinterpret_cast
s instead of C-style casts.#pragma once
; standardized header guards (#ifndef ...
) are enough.cstdbool
instead ofbool.h
)adbc_error_to_nif_error
which allowed it to be removed everywhere this function is called.memset
where it is not necessary now that the contents ofNifRes
are not separately allocated.As added benefit, the resulting code is roughly a hundred lines shorter (without sacrificing readability) :blush: .
If you want to view one of these changes separate from the others (e.g. to better understand it): The individual commits have descriptions and each only contain a single change.