Skip to content

FileUtils copyDirectory(File, File, FileFilter, preserveFileDate) clean up#163

Merged
garydgregory merged 2 commits into
apache:masterfrom
michielgkalkman:master
Oct 8, 2020
Merged

FileUtils copyDirectory(File, File, FileFilter, preserveFileDate) clean up#163
garydgregory merged 2 commits into
apache:masterfrom
michielgkalkman:master

Conversation

@michielgkalkman

Copy link
Copy Markdown
Contributor

I found that copyDirectory(final File srcDir, final File destDir, final FileFilter filter, final boolean preserveFileDate) executes getCanonicalPath() multiple times on the same path. I might be wrong, but that seems wasteful. So, I created this pull request.

I created a unit test based on jmh and it seemed to indicate that the performance indeed improves. However, I am not an expert on benchmarking and profiling and I cannot explain all results. Don't hesitate to show where I went wrong and/or might improve.

See https://github.com/michielgkalkman/PmdPlus/tree/master/src/test/java/org/taHjaj/wo/pmdplus/dup/jmh/org/apache/commons/io (or: michielgkalkman/PmdPlus@10d4495) for some background on what I did test..

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.003%) to 89.475% when pulling 1de01b0 on michielgkalkman:master into 4d3a6bb on apache:master.

@garydgregory garydgregory merged commit 75b79c7 into apache:master Oct 8, 2020
@garydgregory

Copy link
Copy Markdown
Member

Looks reasonable even without the performance minor issue, for me, the code is less cluttered with this refactoring. TY! :-)

@garydgregory garydgregory changed the title Tiny performance improvements FileUtils copyDirectory(final File srcDir, final File destDir, final FileFilter filter, final boolean preserveFileDate) clean up Oct 8, 2020
@garydgregory garydgregory changed the title FileUtils copyDirectory(final File srcDir, final File destDir, final FileFilter filter, final boolean preserveFileDate) clean up FileUtils copyDirectory(File, File, FileFilter, preserveFileDate) clean up Oct 8, 2020
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