-
Notifications
You must be signed in to change notification settings - Fork 1
Revert billion suffix logic change due to performance regression #56
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
Conversation
|
@copilot If you think this is a bug, why all of my tests were passed? |
You're absolutely right - all tests passed because this wasn't a functional bug, it was a logic consistency bug. Both versions produce identical output: Position 3 (10^9):
Position 6 (10^18):
The issue was that position 3 took a different code path (fallback) while positions 6+ used the calculation, even though they're part of the same repeating pattern. The fix makes the code logically consistent - all positions now use the uniform |
…ding Co-authored-by: hckhanh <[email protected]>
|
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
|
@copilot But my codspeed report that there is a performance trade off for this. If this is unnecessary to fix, why don't we go back to the old solution? |
Co-authored-by: hckhanh <[email protected]>
You're right - if the change causes a performance regression without fixing any functional issue, it's not worth keeping. Reverted to the original |
|
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.
Pull Request Overview
This PR improves code clarity in the billion suffix logic by removing redundant handling for positionFromRight === 3. The change simplifies the condition to only handle cases where multiple "tỷ" suffixes are needed (position 6 and above).
- Removed unnecessary branch execution for
positionFromRight === 3which produced the same output as the default case - Updated comment to accurately reflect the logic (removed misleading "position 3 = 'tỷ'" reference)
* Handle large number groups in Vietnamese numeral reading Updated logic to repeat "tỷ" based on group position dynamically, ensuring accurate representation for billions, octillions, and undecillions. Added comprehensive test cases to validate the new functionality and edge cases. * Simplified `readVnNumber` string conversion for improved readability * Adjust changeset config and package workspaces for docs Updated changeset configuration to ignore the `docs` directory, preventing unnecessary change tracking. Added `.` as a workspace in `package.json` to ensure proper package management. * Fix billion suffix logic and use new Array() Co-authored-by: hckhanh <[email protected]> * Revert billion suffix logic change due to performance regression (#56) * Initial plan * Clarify billion suffix logic consistency fix in Vietnamese number reading Co-authored-by: hckhanh <[email protected]> * Revert to original logic: use positionFromRight >= 6 for performance Co-authored-by: hckhanh <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: hckhanh <[email protected]> * Apply suggestion from @hckhanh * Apply suggestion from @hckhanh * Update README.md to enhance project description and badge visibility --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]>



Reverts the billion suffix logic change that was made in commit 21d3311 based on performance analysis.
Context
The original code had
positionFromRight >= 6which was changed topositionFromRight >= 3to improve "logic consistency." However, both versions produce identical functional output:' tỷ'(original via fallback, changed via calculation)Decision
After performance analysis via codspeed, the original
positionFromRight >= 6logic has been restored because:Changes Made
Reverted to original logic:
Testing
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.