/** * Adds a dirty region to the end of the dirty-region queue. * * @param dr the dirty region to add */ public void addDirtyRegion(DirtyRegion dr) { // If the dirty region being added is directly after the last dirty // region on the queue then merge the two dirty regions together. DirtyRegion lastDR= getLastDirtyRegion(); boolean wasMerged= false; if (lastDR != null) if (lastDR.getType() == dr.getType()) if (lastDR.getType() == DirtyRegion.INSERT) { if (lastDR.getOffset() + lastDR.getLength() == dr.getOffset()) { lastDR.mergeWith(dr); wasMerged= true; } } else if (lastDR.getType() == DirtyRegion.REMOVE) { if (dr.getOffset() + dr.getLength() == lastDR.getOffset()) { lastDR.mergeWith(dr); wasMerged= true; } } if (!wasMerged) // Don't merge- just add the new one onto the queue. fDirtyRegions.add(dr); }
/** * Adds a dirty region to the end of the dirty-region queue. * * @param dr the dirty region to add */ public void addDirtyRegion(DirtyRegion dr) { // If the dirty region being added is directly after the last dirty // region on the queue then merge the two dirty regions together. DirtyRegion lastDR= getLastDirtyRegion(); boolean wasMerged= false; if (lastDR != null) if (lastDR.getType() == dr.getType()) if (lastDR.getType() == DirtyRegion.INSERT) { if (lastDR.getOffset() + lastDR.getLength() == dr.getOffset()) { lastDR.mergeWith(dr); wasMerged= true; } } else if (lastDR.getType() == DirtyRegion.REMOVE) { if (dr.getOffset() + dr.getLength() == lastDR.getOffset()) { lastDR.mergeWith(dr); wasMerged= true; } } if (!wasMerged) // Don't merge- just add the new one onto the queue. fDirtyRegions.add(dr); }