Mercurial > hg > RemoteEditor > REPSessionManager
changeset 348:1bc132a6b879
10/14
author | tkaito |
---|---|
date | Tue, 14 Oct 2008 23:03:29 +0900 |
parents | 86935b872385 |
children | ef4afcae0c92 |
files | rep/optimizers/DeleteInsertOptimizer.java |
diffstat | 1 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/optimizers/DeleteInsertOptimizer.java Tue Oct 14 09:33:31 2008 +0900 +++ b/rep/optimizers/DeleteInsertOptimizer.java Tue Oct 14 23:03:29 2008 +0900 @@ -8,7 +8,7 @@ /** * - * @author Takano + * @author Tagano * */ public class DeleteInsertOptimizer implements REPCommandOptimizer { @@ -27,6 +27,10 @@ case REPCMD_DELETE: optimizedAdd(output,r,i); break; + case REPCMD_NOP: + output.remove(r); + i--; + break; } } java.util.Collections.reverse(output); @@ -36,17 +40,14 @@ private void optimizedAdd(List<REPCommand> output, REPCommand r, int ln) { int lineno = r.lineno; - int minln = output.size(); for(int i = ln; i < output.size(); i++){ REPCommand s = output.get(i); if(s.cmd==REP.REPCMD_INSERT) { if(s.lineno < lineno){ lineno --; }else if(s.lineno == lineno){ - if(s.lineno < minln){ - minln = s.lineno; - } - lineNumberCorrection(output,minln,i,ln); + + lineNumberCorrection(output,r.lineno,i,ln); output.remove(r); output.remove(s); ln--; @@ -56,8 +57,6 @@ if(s.lineno < lineno){ lineno ++; } - }else if(s.cmd==REP.REPCMD_NOP){ - output.remove(s); }else{ System.out.println("There are no such commands."); } @@ -67,7 +66,10 @@ private void lineNumberCorrection(List<REPCommand> opt, int ln, int count, int r){ for(int i = r; i < count; i++){ REPCommand o = opt.get(i); - if(ln < o.lineno) o.lineno -= 1; + if(o.lineno == 0){ + }else if(ln < o.lineno){ + o.lineno -= 1; + } } }