Skip to content

Use initial capacity for map if possible#1057

Merged
kingthorin merged 2 commits intodatafaker-net:mainfrom
snuyanzin:map2
Jan 14, 2024
Merged

Use initial capacity for map if possible#1057
kingthorin merged 2 commits intodatafaker-net:mainfrom
snuyanzin:map2

Conversation

@snuyanzin
Copy link
Collaborator

No description provided.

@what-the-diff
Copy link

what-the-diff bot commented Jan 13, 2024

PR Summary

This pull request modifies several files in our codebase to make our program more efficient and code cleaner.

  • Refactoring of Xml.java and BaseFaker.java
    These files have been updated to better create and initialize maps, which can significantly increase the performance in our code. Drop of java.util.HashMap import statement reduces dependencies and makes our code less complex.

  • Improvements in FakeValues.java
    We've addressed the way our program creates nested maps, making it more efficient. There's also a change in the way we're utilizing the HashMap constructor which should enhance the code performance as well.

  • Brightening up FakeValuesService.java
    Several if statements have been converted to the new switch expression syntax. It's a fresh Java feature that makes our code more readable and streamlined.

  • Cleaning up JsonTransformer.java and XmlTransformer.java
    Removed unnecessary import statements from these files and adjusted the createEscapeMap() method for cleaner code and better performance. Plus, the code inside the pretty() method definition in XmlTransformer.java got an indentation fix for better readability.

  • Maintaining the BaseFakerTest.java test file
    Cleaned up some import statements that were no longer used. Also, the fakeValuesHaveReproducibleValues() method name has been changed to fakeValuesHaveReproducibleValuesTest(). The new name better suits the function of the method, making the code easier to read and understand for everyone.

@codecov-commenter
Copy link

codecov-commenter commented Jan 13, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (e90cc2f) 92.18% compared to head (517d10b) 92.10%.
Report is 1 commits behind head on main.

Files Patch % Lines
...n/java/net/datafaker/providers/base/BaseFaker.java 62.50% 3 Missing ⚠️
.../java/net/datafaker/service/FakeValuesService.java 75.00% 1 Missing and 1 partial ⚠️

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

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1057      +/-   ##
============================================
- Coverage     92.18%   92.10%   -0.09%     
+ Complexity     2762     2760       -2     
============================================
  Files           291      291              
  Lines          5543     5536       -7     
  Branches        600      599       -1     
============================================
- Hits           5110     5099      -11     
- Misses          276      280       +4     
  Partials        157      157              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kingthorin kingthorin merged commit 8aa5490 into datafaker-net:main Jan 14, 2024
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