source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSRule.java@ 7056

Last change on this file since 7056 was 7056, checked in by bastiK, 10 years ago

mapcss: optimization by converting very hot double loop into single loop (gain ~ 20%)

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.mapcss;
3
4import java.util.List;
5
6import org.openstreetmap.josm.gui.mappaint.Environment;
7import org.openstreetmap.josm.tools.Utils;
8
9public class MapCSSRule {
10
11 public Selector selector;
12 public Declaration declaration;
13
14 public static class Declaration {
15 public List<Instruction> instructions;
16 // usedId is an optimized way to make sure that
17 // each declaration is only applied once for each primitive,
18 // even if multiple of the comma separated selectors in the
19 // rule match.
20 public int usedId;
21
22 public Declaration(List<Instruction> instructions) {
23 this.instructions = instructions;
24 usedId = 0;
25 }
26 }
27
28 public MapCSSRule(Selector selector, Declaration declaration) {
29 this.selector = selector;
30 this.declaration = declaration;
31 }
32
33 /**
34 * <p>Executes the instructions against the environment {@code env}</p>
35 *
36 * @param env the environment
37 */
38 public void execute(Environment env) {
39 for (Instruction i : declaration.instructions) {
40 i.execute(env);
41 }
42 }
43
44 @Override
45 public String toString() {
46 return selector + " {\n " + Utils.join("\n ", declaration.instructions) + "\n}";
47 }
48}
49
Note: See TracBrowser for help on using the repository browser.