Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 258:e5776067b3b8
Reduce number of objects instantiated on revlog read
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Tue, 16 Aug 2011 22:08:15 +0200 |
| parents | 0e01f9182e16 |
| children | 31f67be94e71 |
comparison
equal
deleted
inserted
replaced
| 257:f39fb6b3cc76 | 258:e5776067b3b8 |
|---|---|
| 20 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 20 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
| 21 | 21 |
| 22 import java.io.File; | 22 import java.io.File; |
| 23 import java.io.IOException; | 23 import java.io.IOException; |
| 24 import java.util.ArrayList; | 24 import java.util.ArrayList; |
| 25 import java.util.LinkedList; | |
| 26 import java.util.List; | 25 import java.util.List; |
| 27 | 26 |
| 28 import org.tmatesoft.hg.core.HgBadStateException; | 27 import org.tmatesoft.hg.core.HgBadStateException; |
| 29 import org.tmatesoft.hg.core.Nodeid; | 28 import org.tmatesoft.hg.core.Nodeid; |
| 30 import org.tmatesoft.hg.repo.HgRepository; | 29 import org.tmatesoft.hg.repo.HgRepository; |
| 392 // don't need to clean lastUserData as it's always null when !needData | 391 // don't need to clean lastUserData as it's always null when !needData |
| 393 i = start; | 392 i = start; |
| 394 } | 393 } |
| 395 | 394 |
| 396 daIndex.seek(getIndexOffsetInt(i)); | 395 daIndex.seek(getIndexOffsetInt(i)); |
| 396 // | |
| 397 final ArrayList<PatchRecord> patches = new ArrayList<PatchRecord>(); | |
| 397 | 398 |
| 398 for (; i <= end; i++ ) { | 399 for (; i <= end; i++ ) { |
| 399 if (inline && needData) { | 400 if (inline && needData) { |
| 400 // inspector reading data (though FilterDataAccess) may have affected index position | 401 // inspector reading data (though FilterDataAccess) may have affected index position |
| 401 daIndex.seek(getIndexOffsetInt(i)); | 402 daIndex.seek(getIndexOffsetInt(i)); |
| 441 } | 442 } |
| 442 } | 443 } |
| 443 // XXX | 444 // XXX |
| 444 if (patchToPrevious) { | 445 if (patchToPrevious) { |
| 445 // this is a patch | 446 // this is a patch |
| 446 LinkedList<PatchRecord> patches = new LinkedList<PatchRecord>(); | |
| 447 while (!userDataAccess.isEmpty()) { | 447 while (!userDataAccess.isEmpty()) { |
| 448 PatchRecord pr = PatchRecord.read(userDataAccess); | 448 PatchRecord pr = PatchRecord.read(userDataAccess); |
| 449 // System.out.printf("PatchRecord:%d %d %d\n", pr.start, pr.end, pr.len); | 449 // System.out.printf("PatchRecord:%d %d %d\n", pr.start, pr.end, pr.len); |
| 450 patches.add(pr); | 450 patches.add(pr); |
| 451 } | 451 } |
| 452 userDataAccess.done(); | 452 userDataAccess.done(); |
| 453 // | 453 // |
| 454 byte[] userData = apply(lastUserData, actualLen, patches); | 454 byte[] userData = apply(lastUserData, actualLen, patches); |
| 455 patches.clear(); | |
| 455 userDataAccess = new ByteArrayDataAccess(userData); | 456 userDataAccess = new ByteArrayDataAccess(userData); |
| 456 } | 457 } |
| 457 } else { | 458 } else { |
| 458 if (inline) { | 459 if (inline) { |
| 459 daIndex.skip(compressedLen); | 460 daIndex.skip(compressedLen); |
