Skip to content
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

Don't use StringBuilder in getValidSsn since length could be predicted #974

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

snuyanzin
Copy link
Collaborator

This allows to speed up the method in about 30-40%

@snuyanzin snuyanzin changed the title Zhcn Don't use StringBuilder in getValidSsn since length could be predicted Sep 26, 2023
@what-the-diff
Copy link

what-the-diff bot commented Sep 26, 2023

PR Summary

  • Modification in ZhCnIdNumber.java File
    The java file for our Identification Number system underwent changes to improve its functionality and performance.

  • Update in getValidSsn Method
    This change is about simplifying the method for creating a valid Social Security Number. Instead of using multiple variables and notably removing s, results are now stored and manipulated directly in the res array.

  • Introducing New Location Setting
    The location variable loc has now been configured to select an option from a predefined list of locations. This change can lead to better accuracy and a wider range of options in our data.

  • Major Updates in generateDay Method

    1. The generateDay method will now take an additional input parameter. This new parameter allows for easier manipulation of dates directly by altering the res array.
    2. The direct assignment of values to res is done instead of using a StringBuilder, streamlining the process to create and set date values.
    3. The method now correctly places year, month, and day values in the right positions within the res array. This feature significantly improves the clarity of the information provided.
  • Changes in ID String Generation
    In previous versions, the tenth character in the ID string was manualy configured as 'X'. In this update, 'X' is directly assigned to the res array, simplifying the whole process. The final ID string is now directly returned from the res array, avoiding unnecessary conversions. This change can lead to more efficient ID generation.

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2023

Codecov Report

Merging #974 (7932c44) into main (b6822df) will increase coverage by 0.04%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@             Coverage Diff              @@
##               main     #974      +/-   ##
============================================
+ Coverage     92.34%   92.38%   +0.04%     
- Complexity     2760     2761       +1     
============================================
  Files           289      289              
  Lines          5513     5518       +5     
  Branches        602      601       -1     
============================================
+ Hits           5091     5098       +7     
  Misses          268      268              
+ Partials        154      152       -2     
Files Coverage Δ
...ain/java/net/datafaker/idnumbers/ZhCnIdNumber.java 90.56% <100.00%> (+3.06%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kingthorin
Copy link
Collaborator

Thanks!

@kingthorin kingthorin merged commit 2bdfea7 into datafaker-net:main Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants