[PATCH v1] Add --no-sort-roads option

The attached patch adds an option (no-sort-roads) to turn off the generation of sorted road data. Hopefully, that process can be made more efficient (if that is indeed where the time is going) but in the meantime this option can be used to restore the performance to it's previous level. Cheers, Mark

Mark, On Sat, Apr 04, 2009 at 12:10:54PM +0100, Mark Burton wrote:
for (RoadDef rd : roads) { rd.writeRgnOffsets(rgn); - Label[] l = rd.getLabels(); - for(int i = 0; i < l.length && l[i] != null; ++i) - if(l[i].getLength() != 0) - sortedRoads.add(new Sortable<Label, RoadDef>(l[i], rd)); + if(sortRoads) { + Label[] l = rd.getLabels(); + for(int i = 0; i < l.length && l[i] != null; ++i) + if(l[i].getLength() != 0) + sortedRoads.add(new Sortable<Label, RoadDef>(l[i], rd)); + } } if(sortedRoads.size() > 0) {
The patch you suggest would do a busy loop of all roads when sortRoads==false. Can you move the if (sortRoads) before the for statement? (Also the sortedRoads.size() check could be skipped if !sortRoads, but that shouldn't cost much CPU, as it will only be performed once.) Marko

Hi Marko,
On Sat, Apr 04, 2009 at 12:10:54PM +0100, Mark Burton wrote:
for (RoadDef rd : roads) { rd.writeRgnOffsets(rgn); - Label[] l = rd.getLabels(); - for(int i = 0; i < l.length && l[i] != null; ++i) - if(l[i].getLength() != 0) - sortedRoads.add(new Sortable<Label, RoadDef>(l[i], rd)); + if(sortRoads) { + Label[] l = rd.getLabels(); + for(int i = 0; i < l.length && l[i] != null; ++i) + if(l[i].getLength() != 0) + sortedRoads.add(new Sortable<Label, RoadDef>(l[i], rd)); + } } if(sortedRoads.size() > 0) {
The patch you suggest would do a busy loop of all roads when sortRoads==false. Can you move the if (sortRoads) before the for statement? (Also the sortedRoads.size() check could be skipped if !sortRoads, but that shouldn't cost much CPU, as it will only be performed once.)
Have you seen the rd.writeRgnOffsets(rgn); at the top of the loop? That was the original content of the loop and it needs to stay. Cheers, Mark

Hi Mark,
The patch you suggest would do a busy loop of all roads when sortRoads==false. Can you move the if (sortRoads) before the for statement? (Also the sortedRoads.size() check could be skipped if !sortRoads, but that shouldn't cost much CPU, as it will only be performed once.)
Have you seen the rd.writeRgnOffsets(rgn); at the top of the loop? That was the original content of the loop and it needs to stay.
Ah, I feel stupid. Sorry for the noise. Marko
participants (2)
-
Mark Burton
-
Marko Mäkelä