Global Metrics
path: .metrics.cyclomatic.sum
old: 14.0
new: 113.0
path: .metrics.cyclomatic.average
old: 1.4
new: 4.035714285714286
path: .metrics.nargs.average
old: 0.7142857142857143
new: 1.4285714285714286
path: .metrics.nargs.sum
old: 5.0
new: 20.0
path: .metrics.nexits.sum
old: 2.0
new: 49.0
path: .metrics.nexits.average
old: 0.2857142857142857
new: 3.5
path: .metrics.nom.functions
old: 7.0
new: 12.0
path: .metrics.nom.closures
old: 0.0
new: 2.0
path: .metrics.nom.total
old: 7.0
new: 14.0
path: .metrics.cognitive.sum
old: 3.0
new: 100.0
path: .metrics.cognitive.average
old: 0.42857142857142855
new: 7.142857142857143
path: .metrics.mi.mi_original
old: 64.98617869039423
new: -8.601013945156254
path: .metrics.mi.mi_sei
old: 49.63315310638415
new: -53.11423339375398
path: .metrics.mi.mi_visual_studio
old: 38.00361326923639
new: 0.0
path: .metrics.loc.lloc
old: 10.0
new: 179.0
path: .metrics.loc.ploc
old: 42.0
new: 470.0
path: .metrics.loc.sloc
old: 63.0
new: 582.0
path: .metrics.loc.blank
old: 10.0
new: 54.0
path: .metrics.loc.cloc
old: 11.0
new: 58.0
path: .metrics.halstead.length
old: 165.0
new: 2008.0
path: .metrics.halstead.level
old: 0.06525573192239859
new: 0.016273813367775267
path: .metrics.halstead.N1
old: 102.0
new: 1193.0
path: .metrics.halstead.bugs
old: 0.19928545039902384
new: 3.353981387572876
path: .metrics.halstead.purity_ratio
old: 1.623081360934744
new: 1.100446108681691
path: .metrics.halstead.N2
old: 63.0
new: 815.0
path: .metrics.halstead.n2
old: 37.0
new: 252.0
path: .metrics.halstead.vocabulary
old: 55.0
new: 290.0
path: .metrics.halstead.difficulty
old: 15.324324324324325
new: 61.448412698412696
path: .metrics.halstead.estimated_program_length
old: 267.8084245542328
new: 2209.6957862328354
path: .metrics.halstead.n1
old: 18.0
new: 38.0
path: .metrics.halstead.effort
old: 14618.24616212972
new: 1009305.9986342604
path: .metrics.halstead.time
old: 812.1247867849844
new: 56072.55547968113
path: .metrics.halstead.volume
old: 953.9243527315688
new: 16425.25745274999
Spaces Data
Minimal test - lines (93, 93)
path: .spaces[0].spaces[0].metrics.nom.functions
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nom.total
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.mi.mi_sei
old: 102.79291085084688
new: null
path: .spaces[0].spaces[0].metrics.mi.mi_original
old: 123.58129616512124
new: null
path: .spaces[0].spaces[0].metrics.mi.mi_visual_studio
old: 72.26976383925219
new: null
path: .spaces[0].spaces[0].metrics.nexits.sum
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.nexits.average
old: 1.0
new: null
path: .spaces[0].spaces[0].metrics.halstead.estimated_program_length
old: 35.60964047443681
new: null
path: .spaces[0].spaces[0].metrics.halstead.length
old: 15.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.n2
old: 5.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.time
old: 14.80175887256437
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.level
old: 0.20833333333333337
new: null
path: .spaces[0].spaces[0].metrics.halstead.effort
old: 266.43165970615865
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.N1
old: 9.0
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.n1
old: 8.0
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.bugs
old: 0.013801807486869684
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.N2
old: 6.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.vocabulary
old: 13.0
new: 1.0
path: .spaces[0].spaces[0].metrics.halstead.difficulty
old: 4.8
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.volume
old: 55.506595772116384
new: 0.0
path: .spaces[0].spaces[0].metrics.halstead.purity_ratio
old: 2.3739760316291205
new: null
path: .spaces[0].spaces[0].metrics.nargs.average
old: 1.0
new: null
path: .spaces[0].spaces[0].metrics.nargs.sum
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.lloc
old: 1.0
new: 0.0
path: .spaces[0].spaces[0].metrics.loc.ploc
old: 5.0
new: 1.0
path: .spaces[0].spaces[0].metrics.loc.sloc
old: 5.0
new: 1.0
path: .spaces[0].spaces[0].metrics.cognitive.average
old: 0.0
new: null
path: .spaces[0].spaces[0].metrics.cyclomatic.sum
old: 2.0
new: 1.0
Code
struct stat buf;
Minimal test - lines (49, 131)
path: .spaces[0].metrics.nexits.sum
old: 2.0
new: 13.0
path: .spaces[0].metrics.nexits.average
old: 0.2857142857142857
new: 13.0
path: .spaces[0].metrics.loc.blank
old: 7.0
new: 8.0
path: .spaces[0].metrics.loc.cloc
old: 1.0
new: 11.0
path: .spaces[0].metrics.loc.lloc
old: 10.0
new: 33.0
path: .spaces[0].metrics.loc.ploc
old: 38.0
new: 64.0
path: .spaces[0].metrics.loc.sloc
old: 46.0
new: 83.0
path: .spaces[0].metrics.nargs.average
old: 0.7142857142857143
new: 2.0
path: .spaces[0].metrics.nargs.sum
old: 5.0
new: 2.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 41.21618900210258
new: 33.187421422038305
path: .spaces[0].metrics.mi.mi_original
old: 70.47968319359542
new: 56.750490631685494
path: .spaces[0].metrics.mi.mi_sei
old: 38.625247826741905
new: 34.32593717620926
path: .spaces[0].metrics.cyclomatic.sum
old: 13.0
new: 14.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.4444444444444444
new: 7.0
path: .spaces[0].metrics.nom.total
old: 7.0
new: 1.0
path: .spaces[0].metrics.nom.functions
old: 7.0
new: 1.0
path: .spaces[0].metrics.halstead.level
old: 0.06296296296296296
new: 0.027255029201817004
path: .spaces[0].metrics.halstead.time
old: 814.8275597107562
new: 4014.17102851816
path: .spaces[0].metrics.halstead.vocabulary
old: 52.0
new: 65.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 248.03238662847315
new: 330.5192567460192
path: .spaces[0].metrics.halstead.difficulty
old: 15.882352941176473
new: 36.69047619047619
path: .spaces[0].metrics.halstead.bugs
old: 0.19972735703771655
new: 0.5782615688461317
path: .spaces[0].metrics.halstead.n1
old: 18.0
new: 23.0
path: .spaces[0].metrics.halstead.n2
old: 34.0
new: 42.0
path: .spaces[0].metrics.halstead.volume
old: 923.4712343388568
new: 1969.3142748603043
path: .spaces[0].metrics.halstead.N1
old: 102.0
new: 193.0
path: .spaces[0].metrics.halstead.N2
old: 60.0
new: 134.0
path: .spaces[0].metrics.halstead.effort
old: 14666.89607479361
new: 72255.07851332688
path: .spaces[0].metrics.halstead.length
old: 162.0
new: 327.0
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.531064114990575
new: 1.0107622530459304
path: .spaces[0].metrics.cognitive.sum
old: 3.0
new: 15.0
path: .spaces[0].metrics.cognitive.average
old: 0.42857142857142855
new: 15.0
Code
bool mozilla::fallocate(PRFileDesc* aFD, int64_t aLength) {
# if defined(HAVE_POSIX_FALLOCATE)
return posix_fallocate(PR_FileDesc2NativeHandle(aFD), 0, aLength) == 0;
# elif defined(XP_WIN)
int64_t oldpos = PR_Seek64(aFD, 0, PR_SEEK_CUR);
if (oldpos == -1) {
return false;
}
if (PR_Seek64(aFD, aLength, PR_SEEK_SET) != aLength) {
return false;
}
bool retval = (0 != SetEndOfFile((HANDLE)PR_FileDesc2NativeHandle(aFD)));
PR_Seek64(aFD, oldpos, PR_SEEK_SET);
return retval;
# elif defined(XP_MACOSX)
int fd = PR_FileDesc2NativeHandle(aFD);
fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, aLength};
// Try to get a continous chunk of disk space
int ret = fcntl(fd, F_PREALLOCATE, &store);
if (ret == -1) {
// OK, perhaps we are too fragmented, allocate non-continuous
store.fst_flags = F_ALLOCATEALL;
ret = fcntl(fd, F_PREALLOCATE, &store);
if (ret == -1) {
return false;
}
}
return ftruncate(fd, aLength) == 0;
# elif defined(XP_UNIX)
// The following is copied from fcntlSizeHint in sqlite
/* If the OS does not have posix_fallocate(), fake it. First use
** ftruncate() to set the file size, then write a single byte to
** the last byte in each block within the extended region. This
** is the same technique used by glibc to implement posix_fallocate()
** on systems that do not have a real fallocate() system call.
*/
int64_t oldpos = PR_Seek64(aFD, 0, PR_SEEK_CUR);
if (oldpos == -1) {
return false;
}
struct stat buf;
int fd = PR_FileDesc2NativeHandle(aFD);
if (fstat(fd, &buf)) {
return false;
}
if (buf.st_size >= aLength) {
return false;
}
const int nBlk = buf.st_blksize;
if (!nBlk) {
return false;
}
if (ftruncate(fd, aLength)) {
return false;
}
int nWrite; // Return value from write()
int64_t iWrite = ((buf.st_size + 2 * nBlk - 1) / nBlk) * nBlk -
1; // Next offset to write to
while (iWrite < aLength) {
nWrite = 0;
if (PR_Seek64(aFD, iWrite, PR_SEEK_SET) == iWrite) {
nWrite = PR_Write(aFD, "", 1);
}
if (nWrite != 1) {
break;
}
iWrite += nBlk;
}
PR_Seek64(aFD, oldpos, PR_SEEK_SET);
return nWrite == 1;
# endif
return false;
}