Ignore:
Timestamp:
2014-05-05T13:26:03+02:00 (10 years ago)
Author:
bastiK
Message:

see #9691 - add back reverted optimization [7056] (modified so it is thread safe)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r7057 r7064  
    1818import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction;
    1919import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule;
     20import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule.Declaration;
    2021import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    2122import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
     
    4849    MapCSSStyleSource sheet;
    4950    StringBuilder sb;
     51    int declarationCounter;
    5052
    5153    /**
     
    7173    public MapCSSParser(InputStream in, String encoding, LexicalState initState) {
    7274        this(createTokenManager(in, encoding, initState));
     75        declarationCounter = 0;
    7376    }
    7477
     
    469472void sheet(MapCSSStyleSource sheet):
    470473{
    471     MapCSSRule r;
    472474}
    473475{
     
    476478    (
    477479        try {
    478             r=rule() { if (r != null) { sheet.rules.add(r); } } w()
     480            rule() w()
    479481        } catch (MapCSSException mex) {
    480482            error_skipto(RBRACE, mex);
     
    488490}
    489491
    490 MapCSSRule rule():
     492void rule():
    491493{
    492494    List<Selector> selectors = new ArrayList<Selector>();
    493495    Selector sel;
    494     List<Instruction> decl;
     496    Declaration decl;
    495497}
    496498{
     
    501503    )*
    502504    decl=declaration()
    503     { return new MapCSSRule(selectors, decl); }
     505    {
     506        for (Selector s : selectors) {
     507            sheet.rules.add(new MapCSSRule(s, decl));
     508        }
     509    }
    504510}
    505511
     
    707713}
    708714
    709 List<Instruction> declaration() :
     715Declaration declaration() :
    710716{
    711717    List<Instruction> ins = new ArrayList<Instruction>();
     
    723729            ( <EQUAL> val=expression() )?
    724730            { ins.add(new Instruction.AssignmentInstruction(key.image, val == null ? true : val, true)); }
    725             ( <RBRACE> { return ins; } | <SEMICOLON> w() )
     731            ( <RBRACE> { return new Declaration(ins, declarationCounter++); } | <SEMICOLON> w() )
    726732        )
    727733    |
     
    732738                { ins.add(new Instruction.AssignmentInstruction(key.image, val, false)); }
    733739                w()
    734                 ( <RBRACE> { return ins; } | <SEMICOLON> w() )
     740                ( <RBRACE> { return new Declaration(ins, declarationCounter++); } | <SEMICOLON> w() )
    735741            |
    736742            LOOKAHEAD( expression() ( <SEMICOLON> | <RBRACE> ) )
    737743                val=expression()
    738744                { ins.add(new Instruction.AssignmentInstruction(key.image, val, false)); }
    739                 ( <RBRACE> { return ins; } | <SEMICOLON> w() )
     745                ( <RBRACE> { return new Declaration(ins, declarationCounter++); } | <SEMICOLON> w() )
    740746            |
    741747                val=readRaw() w() { ins.add(new Instruction.AssignmentInstruction(key.image, val, false)); }
     
    743749    )*
    744750    <RBRACE>
    745     { return ins; }
     751    { return new Declaration(ins, declarationCounter++); }
    746752}
    747753
Note: See TracChangeset for help on using the changeset viewer.