Showcase
-12 lines+8 lines1 method extracted
BEFORE
1 2 3 4
@Override
public TempBlockMeta allocateBlock(long userId, long blockId, long blockSize,
BlockStoreLocation location) throws IOException {
StorageDir candidateDir = null;
5
long maxFreeBytes = blockSize;
6
if (location.equals(BlockStoreLocation.anyTier())) {
7
for (StorageTier tier : mMetaManager.getTiers()) {
×2 DUPLICATED
8
for (StorageDir dir : tier.getStorageDirs()) {
9
if (dir.getAvailableBytes() >= maxFreeBytes) {
10
maxFreeBytes = dir.getAvailableBytes();
11
candidateDir = dir;
12
}
13
}
14
}
15 16 17
} else if (location.equals(BlockStoreLocation.anyDirInTier(location.tierAlias()))) {
StorageTier tier = mMetaManager.getTier(location.tierAlias());
18
for (StorageDir dir : tier.getStorageDirs()) {
19
if (dir.getAvailableBytes() >= maxFreeBytes) {
20
maxFreeBytes = dir.getAvailableBytes();
21
candidateDir = dir;
22
}
23
}
24 25 26 27
}
return candidateDir != null ?
new TempBlockMeta(userId, blockId, blockSize, candidateDir) : null;
}
AFTER
1 2 3 4 5 6
@Override
public TempBlockMeta allocateBlock(long userId, long blockId, long blockSize,
BlockStoreLocation location) throws IOException {
StorageDir candidateDir = null;
if (location.equals(BlockStoreLocation.anyTier())) {
for (StorageTier tier : mMetaManager.getTiers()) {
7
candidateDir = getCandidateDirInTier(tier, blockSize);
8
if (candidateDir != null) {
9
return new TempBlockMeta(userId, blockId, blockSize, candidateDir);
10 11 12 13 14
}
}
} else if (location.equals(BlockStoreLocation.anyDirInTier(location.tierAlias()))) {
StorageTier tier = mMetaManager.getTier(location.tierAlias());
15
candidateDir = getCandidateDirInTier(tier, blockSize);
16 17 18 19
}
return candidateDir != null ?
new TempBlockMeta(userId, blockId, blockSize, candidateDir) : null;
}
... continued in same file ...
NEW METHODsame file, line 98
98
private StorageDir getCandidateDirInTier(StorageTier tier, long blockSize) {
99
StorageDir candidateDir = null;
100
long maxFreeBytes = blockSize - 1;
101
for (StorageDir dir : tier.getStorageDirs()) {
102
if (dir.getAvailableBytes() > maxFreeBytes) {
103
maxFreeBytes = dir.getAvailableBytes();
104
candidateDir = dir;
105
}
106
}
107
return candidateDir;
108
}
Additional Features
Make any codebase agent-native
AIs do best when they can test the app and read logs like a human would. Command Center sets this up for you.
Undo AI Mistakes
When an agent messes things up, simply restore an old snapshot. No need to make extra commits.
Quality Code, No IDE
Give line-by-line feedback directly to your agent from the code-review interface. Meet the highest quality bar without ever touching a line yourself.
Control an Agent Army
Control many agents in their own isolated environments, with extra psychological cues to make context-switching a breeze.
Join the Alpha Waitlist
We'll only email you about the alpha. No spam—ever.