-
-
Notifications
You must be signed in to change notification settings - Fork 758
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
ICU-22940 MF2 ICU4C: Error checking improvements in parser #3306
Conversation
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.
Thanks for working on this.
} | ||
|
||
UnicodeSet* result = new UnicodeSet(*unisets::getImpl(unisets::ALPHA)); | ||
unisets::gUnicodeSets[unisets::ALPHA] = initAlpha(status); |
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.
why not just
UnicodeSet* isAlpha = unisets::gUnicodeSets[unisets::ALPHA] = initAlpha(status);
if (U_FAILURE(status)) {
return 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.
Fixed in e2990d2
} | ||
|
||
unisets::gUnicodeSets[unisets::NAME_START] = initNameStartChars(status); |
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 think you can simplified to
UnicodeSet* nameStart = unisets::gUnicodeSets[unisets::NAME_START] = initNameStartChars(status);
UnicodeSet* digit = unisets::gUnicodeSets[unisets:: DIGIT] = initDigits(status);
if (U_FAILURE(status)) {
return 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.
Fixed in e2990d2
} | ||
|
||
unisets::gUnicodeSets[unisets::CONTENT] = initContentChars(status); |
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 think you can simplfied to
UnicodeSet* content = unisets::gUnicodeSets[unisets::CONTENT] = initContentChars(status);
UnicodeSet* whitespace = unisets::gUnicodeSets[unisets::WHITESPACE] = initWhitespace(status);
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.
Fixed in e2990d2
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.
Thanks
initTextChars depends on | ||
initContentChars | ||
initWhitespace | ||
*/ |
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 think in the end of this function, we should do the following
if (U_FAILURE(status)) {
cleanupMF2ParseUniSets();
}
so in case the failure is due to memory stress for the initialization, gMF2ParseUniSetsInitOnce will be reset after all the allocated UnicodeSet inside gUnicodeSets be deleted so it has a second chance to be sucessful.
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.
Made the change in 7f19865 -- can you re-approve? Thanks!
Improve checking for OOM errors when allocating UnicodeSets, per post-merge comments on unicode-org#3236
7f19865
to
cb61cf1
Compare
Hooray! The files in the branch are the same across the force-push. 😃 ~ Your Friendly Jira-GitHub PR Checker Bot |
Improve checking for OOM errors when allocating UnicodeSets, per post-merge comments on #3236
Checklist