Browse code

Automapping: remove beforehand check if rules are used.

D. Knuth: Premature optimisation is the root of all evil.
And he is right again.

The checks if rules are used have been done before all Automapping takes
place, but a rule can alter the situation for the following rules
drastically, so either we try to correct the checks if rules are applied
or just drop these checks.

The intention of the checking before was to speed up Automapping by only
executing the needed rules, but as the checks would take more and more
code for just being correct, it might be better to remove the speedup
things completely and have a smaller code base.

Thanks to Giancarlo Todone for spotting the bug.

Stefan Beller authored on 07/06/2012 18:44:15
Showing 2 changed files
... ...
@@ -332,9 +332,6 @@ bool AutoMapper::prepareAutoMap()
332 332
     mError.clear();
333 333
     mWarning.clear();
334 334
 
335
-    if (!setupRulesUsedCheck())
336
-        return false;
337
-
338 335
     if (!setupMissingLayers())
339 336
         return false;
340 337
 
... ...
@@ -347,34 +344,6 @@ bool AutoMapper::prepareAutoMap()
347 344
     return true;
348 345
 }
349 346
 
350
-bool AutoMapper::setupRulesUsedCheck()
351
-{
352
-    foreach (const QString &index, mInputRules.indexes) {
353
-        foreach (const QString &name, mInputRules[index].names) {
354
-            const InputIndex &ii = mInputRules[index];
355
-            const int i = mMapWork->indexOfLayer(name, Layer::TileLayerType);
356
-            if (i == -1)
357
-                continue;
358
-
359
-            const TileLayer *setLayer = mMapWork->layerAt(i)->asTileLayer();
360
-            QList<Tileset*> tilesetWork = setLayer->usedTilesets().toList();
361
-
362
-            foreach (const TileLayer *tilelayer, ii[name].listYes)
363
-                foreach (Tileset *tileset, tilelayer->usedTilesets())
364
-                    if (tileset->findSimilarTileset(tilesetWork)
365
-                            || tilesetWork.contains(tileset))
366
-                        return true;
367
-
368
-            foreach (const TileLayer *tilelayer, ii[name].listNo)
369
-                foreach (Tileset *tileset, tilelayer->usedTilesets())
370
-                    if (tileset->findSimilarTileset(tilesetWork)
371
-                            || tilesetWork.contains(tileset))
372
-                        return true;
373
-        }
374
-    }
375
-    return false;
376
-}
377
-
378 347
 bool AutoMapper::setupMissingLayers()
379 348
 {
380 349
     // make sure all needed layers are there:
... ...
@@ -256,12 +256,6 @@ private:
256 256
     void cleanTileLayers();
257 257
 
258 258
     /**
259
-     * Checks if this the rules from the given rules map could be used anyway
260
-     * by comparing the used tilesets of the set layers and ruleset layer.
261
-     */
262
-    bool setupRulesUsedCheck();
263
-
264
-    /**
265 259
      * where to work in
266 260
      */
267 261
     MapDocument *mMapDocument;