Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Apr 24, 2025

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

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);
Copy link
Member

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());
Copy link
Member

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

@Girgias Girgias marked this pull request as ready for review April 26, 2025 12:10
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);
Copy link
Member

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 ?

Copy link
Member

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) ?

@Girgias Girgias closed this Jul 28, 2025
@Girgias
Copy link
Member Author

Girgias commented Jul 28, 2025

Closing as I don't really know C++ and it seems David is already during various refactorings.

@Girgias Girgias deleted the intl-refacto branch July 28, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants