Changeset 11856 in josm


Ignore:
Timestamp:
2017-04-08T01:51:12+02:00 (8 months ago)
Author:
Don-vip
Message:

sonar - fb-contrib:IOI_DOUBLE_BUFFER_COPY - Performance - Method passes a Buffered Stream/Reader/Writer to a already buffering copy method

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r11365 r11856  
    1515import java.awt.event.KeyEvent;
    1616import java.awt.event.MouseEvent;
    17 import java.io.BufferedInputStream;
    1817import java.io.BufferedReader;
    1918import java.io.File;
     
    507506                        tr("Save style ''{0}'' as ''{1}''", s.getDisplayString(), file.getPath()));
    508507                try {
    509                     InputStream in = s.getSourceInputStream();
    510                     try (InputStream bis = new BufferedInputStream(in)) {
    511                         Files.copy(bis, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
    512                     } finally {
    513                         s.closeSourceInputStream(in);
     508                    try (InputStream in = s.getSourceInputStream()) {
     509                        Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
    514510                    }
    515511                } catch (IOException e) {
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r11493 r11856  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.io.BufferedInputStream;
    76import java.io.BufferedReader;
    87import java.io.ByteArrayOutputStream;
     
    483482                throw new IOException(tr("The requested URL {0} was not found", urlStr));
    484483            }
    485             try (InputStream bis = new BufferedInputStream(con.getContent())) {
    486                 Files.copy(bis, destDirFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
     484            try (InputStream is = con.getContent()) {
     485                Files.copy(is, destDirFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
    487486            }
    488487            activeConnection = null;
Note: See TracChangeset for help on using the changeset viewer.