oblac / jodd

Jodd! Lightweight. Java. Zero dependencies. Use what you like.
https://jodd.org
BSD 2-Clause "Simplified" License
4.06k stars 723 forks source link

Optimize empty String tests on Java 9+ #771

Closed slandelle closed 4 years ago

slandelle commented 4 years ago

Motivation:

Don't use String#length() to test emptyness. This computes the actual length, which might be non trivial with Java 9 where the underlying encoding is UTF-8 and not US-ASCII. Use String#isEmpty() instead as it just has to check the length of the nuderlying byte array.

Modifications:

Result:

More performant String emptiness test

codecov[bot] commented 4 years ago

Codecov Report

Merging #771 into master will decrease coverage by 0.01%. The diff coverage is 47.27%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #771      +/-   ##
============================================
- Coverage     65.97%   65.95%   -0.02%     
+ Complexity    10510    10509       -1     
============================================
  Files           837      837              
  Lines         40027    40020       -7     
  Branches       6422     6420       -2     
============================================
- Hits          26407    26397      -10     
- Misses        11552    11556       +4     
+ Partials       2068     2067       -1     
Impacted Files Coverage Δ Complexity Δ
jodd-core/src/main/java/jodd/io/ZipUtil.java 68.79% <0.00%> (ø) 22.00 <2.00> (ø)
...src/main/java/jodd/io/upload/FileUploadHeader.java 63.79% <0.00%> (ø) 10.00 <0.00> (ø)
...ain/java/jodd/io/upload/MultipartStreamParser.java 56.47% <0.00%> (ø) 17.00 <0.00> (ø)
jodd-core/src/main/java/jodd/net/URLCoder.java 85.49% <0.00%> (ø) 39.00 <0.00> (ø)
.../java/jodd/util/ResourceBundleMessageResolver.java 9.27% <0.00%> (ø) 2.00 <0.00> (ø)
...ava/jodd/db/oom/mapper/DefaultResultSetMapper.java 89.65% <0.00%> (ø) 57.00 <0.00> (ø)
...java/jodd/db/oom/sqlgen/chunks/ReferenceChunk.java 76.19% <0.00%> (ø) 9.00 <0.00> (ø)
...ain/java/jodd/db/oom/sqlgen/chunks/TableChunk.java 98.33% <0.00%> (ø) 15.00 <0.00> (ø)
...odd-proxetta/src/main/java/jodd/asm7/TypePath.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...c/main/java/jodd/proxetta/asm/ProxettaAsmUtil.java 64.66% <0.00%> (ø) 118.00 <0.00> (ø)
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d6064aa...fded837. Read the comment docs.

slandelle commented 4 years ago

Honestly, codecov is drunk...

igr commented 4 years ago

Crazy:) Thank you @slandelle!

I am finalizing the migration to v6 and separating/grouping repos atm, so your change will be applied to all new repos plus to whatever remains here.

slandelle commented 4 years ago

Ah OK. Please let me know if you want me to redo this PR on the different projects once the migration is done.

igr commented 4 years ago

No need, thank you! At this moment, just need to do all that by myself, until its finished and released; will be just easier.

igr commented 4 years ago

Fixed in jodd-util and jodd-lagarto