Ignore:
Timestamp:
2013-08-03T00:12:29+02:00 (11 years ago)
Author:
Don-vip
Message:

see #8902 - Small performance enhancements / coding style (patch by shinigami):

  • while -> foreach
  • for -> for each

plus:

  • cleanup of FileDrop class to make it more integrated into JOSM core + remove warnings
Location:
trunk/src/org/openstreetmap/josm/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/FallbackDateParser.java

    r3719 r6104  
    4343        // Build a list of candidate date parsers.
    4444        dateParsers = new ArrayList<DateFormat>(formats.length);
    45         for (int i = 0; i < formats.length; i++) {
    46             dateParsers.add(new SimpleDateFormat(formats[i]));
     45        for (String format : formats) {
     46            dateParsers.add(new SimpleDateFormat(format));
    4747        }
    4848
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r6103 r6104  
    281281        if( path.exists() ) {
    282282            File[] files = path.listFiles();
    283             for(int i=0; i<files.length; i++) {
    284                 if(files[i].isDirectory()) {
    285                     deleteDirectory(files[i]);
    286                 }
    287                 else {
    288                     files[i].delete();
     283            for (File file : files) {
     284                if (file.isDirectory()) {
     285                    deleteDirectory(file);
     286                } else {
     287                    file.delete();
    289288                }
    290289            }
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r6087 r6104  
    296296                .getLocalGraphicsEnvironment();
    297297        GraphicsDevice[] gs = ge.getScreenDevices();
    298         for (int j = 0; j < gs.length; j++) {
    299             GraphicsDevice gd = gs[j];
     298        for (GraphicsDevice gd : gs) {
    300299            if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
    301300                virtualBounds = virtualBounds.union(gd.getDefaultConfiguration().getBounds());
     
    346345        int intersect = 0;
    347346        Rectangle bounds = null;
    348         for (int j = 0; j < gs.length; j++) {
    349             GraphicsDevice gd = gs[j];
     347        for (GraphicsDevice gd : gs) {
    350348            if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
    351349                Rectangle b = gd.getDefaultConfiguration().getBounds();
    352                 if (b.height > 0 && b.width/b.height >= 3) /* multiscreen with wrong definition */
    353                 {
     350                if (b.height > 0 && b.width / b.height >= 3) /* multiscreen with wrong definition */ {
    354351                    b.width /= 2;
    355352                    Rectangle is = b.intersection(g);
    356                     int s = is.width*is.height;
    357                     if(bounds == null || intersect < s) {
     353                    int s = is.width * is.height;
     354                    if (bounds == null || intersect < s) {
    358355                        intersect = s;
    359356                        bounds = b;
     
    362359                    b.x += b.width;
    363360                    is = b.intersection(g);
    364                     s = is.width*is.height;
    365                     if(bounds == null || intersect < s) {
     361                    s = is.width * is.height;
     362                    if (bounds == null || intersect < s) {
    366363                        intersect = s;
    367364                        bounds = b;
    368365                    }
    369                 }
    370                 else
    371                 {
     366                } else {
    372367                    Rectangle is = b.intersection(g);
    373                     int s = is.width*is.height;
    374                     if(bounds == null || intersect < s) {
     368                    int s = is.width * is.height;
     369                    if (bounds == null || intersect < s) {
    375370                        intersect = s;
    376371                        bounds = b;
Note: See TracChangeset for help on using the changeset viewer.