-
Notifications
You must be signed in to change notification settings - Fork 7.8k
ext/intl: BreakIterator clean-up #18419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
static inline RuleBasedBreakIterator *fetch_rbbi(BreakIterator_object *bio) { | ||
return (RuleBasedBreakIterator*)bio->biter; | ||
static inline RuleBasedBreakIterator *fetch_rbbi(const BreakIterator_object *bio) { | ||
return dynamic_cast<RuleBasedBreakIterator *>(bio->biter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: sanity check assigning to a variable and ZEND_ASSERT(var != nullptr);
@@ -34,5 +30,5 @@ U_CFUNC PHP_METHOD(IntlCodePointBreakIterator, getLastCodePoint) | |||
|
|||
BREAKITER_METHOD_FETCH_OBJECT; | |||
|
|||
RETURN_LONG(fetch_cpbi(bio)->getLastCodePoint()); | |||
RETURN_LONG(dynamic_cast<CodePointBreakIterator *>(bio->biter)->getLastCodePoint()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would try to be consistent here
static inline RuleBasedBreakIterator *fetch_rbbi(BreakIterator_object *bio) { | ||
return (RuleBasedBreakIterator*)bio->biter; | ||
static inline RuleBasedBreakIterator *fetch_rbbi(const BreakIterator_object *bio) { | ||
ZEND_ASSERT(bio != nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what makes you think it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may not need this helper no more than you needed the other, especially I see in one instance (i.e. getRuleStatusVec) that the cast seems to be done needlessly twice (was already like this though) ?
Basically I followed CLion's suggestions about "C++ code smells" not sure if we want to do this or not.
@devnexen I let you be the judge as you primarily maintain this extension