Ignore:
Timestamp:
2015-10-10T01:40:42+02:00 (11 years ago)
Author:
Don-vip
Message:

sonar - fb-contrib - minor performance improvements:

  • Method passes constant String of length 1 to character overridden method
  • Method needlessly boxes a boolean constant
  • Method uses iterator().next() on a List to get the first item
  • Method converts String to boxed primitive using excessive boxing
  • Method converts String to primitive using excessive boxing
  • Method creates array using constants
  • Class defines List based fields but uses them like Sets
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r8565 r8846  
    185185            if (n.getCoor() != null) {
    186186                out.print(" lat='"+LatLon.cDdHighPecisionFormatter.format(n.getCoor().lat())+
    187                           "' lon='"+LatLon.cDdHighPecisionFormatter.format(n.getCoor().lon())+"'");
     187                          "' lon='"+LatLon.cDdHighPecisionFormatter.format(n.getCoor().lon())+'\'');
    188188            }
    189189            addTags(n, "node", true);
     
    226226    public void visit(Changeset cs) {
    227227        out.print("  <changeset ");
    228         out.print(" id='"+cs.getId()+"'");
     228        out.print(" id='"+cs.getId()+'\'');
    229229        if (cs.getUser() != null) {
    230             out.print(" user='"+cs.getUser().getName() +"'");
    231             out.print(" uid='"+cs.getUser().getId() +"'");
     230            out.print(" user='"+cs.getUser().getName() +'\'');
     231            out.print(" uid='"+cs.getUser().getId() +'\'');
    232232        }
    233233        if (cs.getCreatedAt() != null) {
    234             out.print(" created_at='"+DateUtils.fromDate(cs.getCreatedAt()) +"'");
     234            out.print(" created_at='"+DateUtils.fromDate(cs.getCreatedAt()) +'\'');
    235235        }
    236236        if (cs.getClosedAt() != null) {
    237             out.print(" closed_at='"+DateUtils.fromDate(cs.getClosedAt()) +"'");
    238         }
    239         out.print(" open='"+ (cs.isOpen() ? "true" : "false") +"'");
     237            out.print(" closed_at='"+DateUtils.fromDate(cs.getClosedAt()) +'\'');
     238        }
     239        out.print(" open='"+ (cs.isOpen() ? "true" : "false") +'\'');
    240240        if (cs.getMin() != null) {
    241             out.print(" min_lon='"+ cs.getMin().lonToString(CoordinateFormat.DECIMAL_DEGREES) +"'");
    242             out.print(" min_lat='"+ cs.getMin().latToString(CoordinateFormat.DECIMAL_DEGREES) +"'");
     241            out.print(" min_lon='"+ cs.getMin().lonToString(CoordinateFormat.DECIMAL_DEGREES) +'\'');
     242            out.print(" min_lat='"+ cs.getMin().latToString(CoordinateFormat.DECIMAL_DEGREES) +'\'');
    243243        }
    244244        if (cs.getMax() != null) {
    245             out.print(" max_lon='"+ cs.getMin().lonToString(CoordinateFormat.DECIMAL_DEGREES) +"'");
    246             out.print(" max_lat='"+ cs.getMin().latToString(CoordinateFormat.DECIMAL_DEGREES) +"'");
     245            out.print(" max_lon='"+ cs.getMin().lonToString(CoordinateFormat.DECIMAL_DEGREES) +'\'');
     246            out.print(" max_lat='"+ cs.getMin().latToString(CoordinateFormat.DECIMAL_DEGREES) +'\'');
    247247        }
    248248        out.println(">");
     
    268268                        "' v='"+XmlWriter.encode(e.getValue())+ "' />");
    269269            }
    270             out.println("  </" + tagname + ">");
     270            out.println("  </" + tagname + '>');
    271271        } else if (tagOpen) {
    272272            out.println(" />");
    273273        } else {
    274             out.println("  </" + tagname + ">");
     274            out.println("  </" + tagname + '>');
    275275        }
    276276    }
     
    283283        out.print("  <"+tagname);
    284284        if (osm.getUniqueId() != 0) {
    285             out.print(" id='"+ osm.getUniqueId()+"'");
     285            out.print(" id='"+ osm.getUniqueId()+'\'');
    286286        } else
    287287            throw new IllegalStateException(tr("Unexpected id 0 for osm primitive found"));
     
    295295                }
    296296                if (action != null) {
    297                     out.print(" action='"+action+"'");
     297                    out.print(" action='"+action+'\'');
    298298                }
    299299            }
    300300            if (!osm.isTimestampEmpty()) {
    301                 out.print(" timestamp='"+DateUtils.fromTimestamp(osm.getRawTimestamp())+"'");
     301                out.print(" timestamp='"+DateUtils.fromTimestamp(osm.getRawTimestamp())+'\'');
    302302            }
    303303            // user and visible added with 0.4 API
    304304            if (osm.getUser() != null) {
    305305                if (osm.getUser().isLocalUser()) {
    306                     out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+"'");
     306                    out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+'\'');
    307307                } else if (osm.getUser().isOsmUser()) {
    308308                    // uid added with 0.6
    309                     out.print(" uid='"+ osm.getUser().getId()+"'");
    310                     out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+"'");
     309                    out.print(" uid='"+ osm.getUser().getId()+'\'');
     310                    out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+'\'');
    311311                }
    312312            }
    313             out.print(" visible='"+osm.isVisible()+"'");
     313            out.print(" visible='"+osm.isVisible()+'\'');
    314314        }
    315315        if (osm.getVersion() != 0) {
    316             out.print(" version='"+osm.getVersion()+"'");
     316            out.print(" version='"+osm.getVersion()+'\'');
    317317        }
    318318        if (this.changeset != null && this.changeset.getId() != 0) {
    319             out.print(" changeset='"+this.changeset.getId()+"'");
     319            out.print(" changeset='"+this.changeset.getId()+'\'');
    320320        } else if (osm.getChangesetId() > 0 && !osm.isNew()) {
    321             out.print(" changeset='"+osm.getChangesetId()+"'");
     321            out.print(" changeset='"+osm.getChangesetId()+'\'');
    322322        }
    323323    }
Note: See TracChangeset for help on using the changeset viewer.