Index: trunk/src/org/openstreetmap/josm/io/OsmReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 1277)
+++ trunk/src/org/openstreetmap/josm/io/OsmReader.java	(revision 1278)
@@ -7,4 +7,6 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.FileInputStream;
+import java.nio.channels.FileChannel;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -50,4 +52,12 @@
 public class OsmReader {
 
+     static long tagsN = 0;
+     static long nodesN = 0;
+     static long waysN = 0;
+     static long relationsN = 0;
+     static long membersN = 0;
+
+     static InputStream currSource;
+
      /**
       * This is used as (readonly) source for finding missing references when not transferred in the
@@ -133,7 +143,21 @@
           private OsmPrimitive current;
           private String generator;
-
+          int n = 0;
+          
           @Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
                try {
+                    if(n%100000 == 0) {
+                        try {
+                            FileInputStream fis = (FileInputStream)currSource;
+                            FileChannel channel = fis.getChannel();
+                            double perc = (((double)channel.position()) / ((double)channel.size()) * 100.0);
+                            System.out.format(" " + (int)perc + "%%");
+                        }
+                        catch(IOException e) {
+                            System.out.format("Error reading file position " + e);
+                        }
+                    }
+                    n++;                    
+
                     if (qName.equals("osm")) {
                          if (atts == null)
@@ -187,8 +211,10 @@
 
                     } else if (qName.equals("node")) {
+                         nodesN++;
                          current = new Node(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon")));
                          readCommon(atts, current);
                          nodes.put(current.id, (Node)current);
                     } else if (qName.equals("way")) {
+                         waysN++;
                          current = new OsmPrimitiveData();
                          readCommon(atts, current);
@@ -206,8 +232,10 @@
 
                     } else if (qName.equals("relation")) {
+                         relationsN++;
                          current = new OsmPrimitiveData();
                          readCommon(atts, current);
                          relations.put((OsmPrimitiveData)current, new LinkedList<RelationMemberData>());
                     } else if (qName.equals("member")) {
+                         membersN++;
                          Collection<RelationMemberData> list = relations.get(current);
                          if (list == null)
@@ -227,4 +255,5 @@
 
                     } else if (qName.equals("tag")) {
+                         tagsN++;
                          current.put(atts.getValue("k"), atts.getValue("v"));
                     }
@@ -365,7 +394,4 @@
       */
      private Way findWay(long id) {
-          for (Way wy : ds.ways)
-               if (wy.id == id)
-                    return wy;
           for (Way wy : Main.ds.ways)
                if (wy.id == id)
@@ -407,4 +433,9 @@
           }
 
+          // Cache the ways here for much better search performance
+          HashMap hm = new HashMap(10000);
+          for (Way wy : ds.ways)
+            hm.put(wy.id, wy);
+          
           // pass 2 - sort out members
           for (Entry<OsmPrimitiveData, Collection<RelationMemberData>> e : relations.entrySet()) {
@@ -421,5 +452,7 @@
                          }
                     } else if (emd.type.equals("way")) {
-                         em.member = findWay(emd.id);
+                         em.member = (OsmPrimitive)hm.get(emd.id);
+                         if (em.member == null)
+                            em.member = findWay(emd.id);
                          if (em.member == null) {
                               em.member = new Way(emd.id);
@@ -438,4 +471,5 @@
                }
           }
+          hm = null;
      }
 
@@ -454,4 +488,7 @@
           osm.references = ref == null ? new DataSet() : ref;
 
+          
+          currSource = source;
+          
           // phase 1: Parse nodes and read in raw ways
           InputSource inputSource = new InputSource(new InputStreamReader(source, "UTF-8"));
@@ -463,8 +500,7 @@
         }
 
-        if (pleaseWaitDlg != null) {
-               pleaseWaitDlg.progress.setValue(0);
-               pleaseWaitDlg.currentAction.setText(tr("Preparing data..."));
-          }
+          System.out.println("");
+          System.out.println("Parser finished: Tags " + tagsN + " Nodes " + nodesN + " Ways " + waysN + 
+            " Relations " + relationsN + " Members " + membersN);
 
           for (Node n : osm.nodes.values())
@@ -484,4 +520,6 @@
                     o.id = 0;
 
+          System.out.println("File loaded!");
+          
           return osm;
      }
