[R-package] Use R standard routines to access character data in C++ #4252
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.
Another step towards #3016.
Similar to the changes for numeric data in #4247, this proposes replacing moost uses of the LightGBM-custom
R_CHAR_PTR
with R's standard interface for accessing character data. Unlike that PR, this requires two steps...extracting aCHARSXP
from the object passed in from R, then getting a pointer to its data (char *
). That results in a pattern like this:CHAR(Rf_asChar(filename))
As a result of these changes, the utility function
lgb.c_str()
is no longer necessary.Notes for Reviewers
[R-package] predict() breaks when using a Dataset stored in a file #4034 is not fixed by this change, but it is partially fixed. As of this PR, the reproducible examples in that issue yield
[LightGBM] [Fatal] Unknown format of training data.
instead of[LightGBM] [Fatal] Data file ��?��V doesn't exist.
. That can be addressed in a followup PR.R_CHAR_PTR
cannot be completely removed in this PR, because it is still used inEncodeChar
. That can be addressed in a future PR.LightGBM/R-package/src/lightgbm_R.cpp
Lines 46 to 57 in bb88d92
References