# Global Metrics

path: .metrics.mi.mi_sei
old: 74.43128795207959
new: 6.700749118307357
path: .metrics.mi.mi_visual_studio
old: 46.515229297634264
new: 17.60675990292833
path: .metrics.mi.mi_original
old: 79.54104209895459
new: 30.10755943400744
path: .metrics.cognitive.sum
old: 1.0
new: 40.0
path: .metrics.cognitive.average
old: null
new: 40.0
path: .metrics.cyclomatic.sum
old: 4.0
new: 28.0
path: .metrics.cyclomatic.average
old: 2.0
new: 14.0
path: .metrics.halstead.N1
old: 21.0
new: 381.0
path: .metrics.halstead.effort
old: 889.4442781126991
new: 139415.69122770452
path: .metrics.halstead.purity_ratio
old: 1.5752008432174336
new: 1.1495840395758334
path: .metrics.halstead.level
old: 0.23703703703703705
new: 0.02891156462585034
path: .metrics.halstead.N2
old: 27.0
new: 210.0
path: .metrics.halstead.length
old: 48.0
new: 591.0
path: .metrics.halstead.bugs
old: 0.03082889148080807
new: 0.8962307683005801
path: .metrics.halstead.vocabulary
old: 21.0
new: 113.0
path: .metrics.halstead.n2
old: 16.0
new: 85.0
path: .metrics.halstead.estimated_program_length
old: 75.60964047443682
new: 679.4041673893175
path: .metrics.halstead.volume
old: 210.83123629338053
new: 4030.725766787376
path: .metrics.halstead.difficulty
old: 4.21875
new: 34.588235294117645
path: .metrics.halstead.n1
old: 5.0
new: 28.0
path: .metrics.halstead.time
old: 49.41357100626106
new: 7745.316179316917
path: .metrics.loc.cloc
old: 12.0
new: 76.0
path: .metrics.loc.lloc
old: 0.0
new: 74.0
path: .metrics.loc.ploc
old: 30.0
new: 104.0
path: .metrics.loc.sloc
old: 48.0
new: 280.0
path: .metrics.loc.blank
old: 6.0
new: 100.0
path: .metrics.nargs.average
old: null
new: 5.0
path: .metrics.nargs.sum
old: 0.0
new: 5.0
path: .metrics.nexits.sum
old: 0.0
new: 2.0
path: .metrics.nexits.average
old: null
new: 2.0
path: .metrics.nom.total
old: 0.0
new: 1.0
path: .metrics.nom.functions
old: 0.0
new: 1.0

# Spaces Data

## Minimal test - lines (65, 174)

path: .spaces[0].metrics.mi.mi_sei
old: 100.85355688986772
new: 12.227487067918556
path: .spaces[0].metrics.mi.mi_visual_studio
old: 71.52492080902456
new: 26.806813016709135
path: .spaces[0].metrics.mi.mi_original
old: 122.307614583432
new: 45.83965025857262
path: .spaces[0].metrics.cognitive.average
old: null
new: 40.0
path: .spaces[0].metrics.cognitive.sum
old: 0.0
new: 40.0
path: .spaces[0].metrics.loc.cloc
old: 0.0
new: 7.0
path: .spaces[0].metrics.loc.lloc
old: 0.0
new: 74.0
path: .spaces[0].metrics.loc.sloc
old: 6.0
new: 110.0
path: .spaces[0].metrics.loc.blank
old: 0.0
new: 13.0
path: .spaces[0].metrics.loc.ploc
old: 6.0
new: 90.0
path: .spaces[0].metrics.nargs.average
old: null
new: 5.0
path: .spaces[0].metrics.nargs.sum
old: 0.0
new: 5.0
path: .spaces[0].metrics.nom.total
old: 0.0
new: 1.0
path: .spaces[0].metrics.nom.functions
old: 0.0
new: 1.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.0
new: 27.0
path: .spaces[0].metrics.cyclomatic.sum
old: 1.0
new: 27.0
path: .spaces[0].metrics.nexits.sum
old: 0.0
new: 2.0
path: .spaces[0].metrics.nexits.average
old: null
new: 2.0
path: .spaces[0].metrics.halstead.level
old: 0.6666666666666666
new: 0.027387120651369355
path: .spaces[0].metrics.halstead.N2
old: 5.0
new: 193.0
path: .spaces[0].metrics.halstead.estimated_program_length
old: 16.36452797660028
new: 594.1054868741552
path: .spaces[0].metrics.halstead.n2
old: 5.0
new: 74.0
path: .spaces[0].metrics.halstead.n1
old: 3.0
new: 28.0
path: .spaces[0].metrics.halstead.length
old: 14.0
new: 563.0
path: .spaces[0].metrics.halstead.time
old: 3.5
new: 7620.320505454902
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.1688948554714484
new: 1.0552495326361548
path: .spaces[0].metrics.halstead.difficulty
old: 1.5
new: 36.51351351351352
path: .spaces[0].metrics.halstead.bugs
old: 0.0052776320879040755
new: 0.8865622613780196
path: .spaces[0].metrics.halstead.effort
old: 63.0
new: 137165.76909818823
path: .spaces[0].metrics.halstead.N1
old: 9.0
new: 370.0
path: .spaces[0].metrics.halstead.vocabulary
old: 8.0
new: 102.0
path: .spaces[0].metrics.halstead.volume
old: 42.0
new: 3756.575467529952

### Code

    PrepareAndDispatch(nsXPTCStubBase * self, uint32_t methodIndex,
                       uint64_t * args, uint64_t * gpregs, double *fpregs)
    {
        nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
        const nsXPTMethodInfo* info;
        uint32_t paramCount;
        uint32_t i;

        NS_ASSERTION(self,"no self");

        self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
        NS_ASSERTION(info,"no method info");
        if (!info)
            return NS_ERROR_UNEXPECTED;

        paramCount = info->GetParamCount();

        const uint8_t indexOfJSContext = info->IndexOfJSContext();

        uint64_t* ap = args;
        // |that| is implicit in the calling convention; we really do start at the
        // first GPR (as opposed to x86_64).
        uint32_t nr_gpr = 0;
        uint32_t nr_fpr = 0;
        uint64_t value;

        for(i = 0; i < paramCount; i++) {
            const nsXPTParamInfo& param = info->GetParam(i);
            const nsXPTType& type = param.GetType();
            nsXPTCMiniVariant* dp = ¶mBuffer[i];

            if (i == indexOfJSContext) {
                if (nr_gpr < GPR_COUNT)
                    nr_gpr++;
                else
                    ap++;
            }

            if (!param.IsOut() && type == nsXPTType::T_DOUBLE) {
                if (nr_fpr < FPR_COUNT) {
                    dp->val.d = fpregs[nr_fpr++];
                    // Even if we have enough FPRs, still skip space in
                    // the parameter area if we ran out of placeholder GPRs.
                    if (nr_gpr < GPR_COUNT) {
                        nr_gpr++;
                    } else {
                        ap++;
                    }
                } else {
                    dp->val.d = *(double*)ap++;
                }
                continue;
            }
            if (!param.IsOut() && type == nsXPTType::T_FLOAT) {
                if (nr_fpr < FPR_COUNT) {
                    // Single-precision floats are passed in FPRs too.
                    dp->val.f = (float)fpregs[nr_fpr++];
                    if (nr_gpr < GPR_COUNT) {
                        nr_gpr++;
                    } else {
                        ap++;
                    }
                } else {
    #ifdef __LITTLE_ENDIAN__
                    dp->val.f = *(float*)ap++;
    #else
                    // Big endian needs adjustment to point to the least
                    // significant word.
                    float* p = (float*)ap;
                    p++;
                    dp->val.f = *p;
                    ap++;
    #endif
                }
                continue;
            }
            if (nr_gpr < GPR_COUNT)
                value = gpregs[nr_gpr++];
            else
                value = *ap++;

            if (param.IsOut() || !type.IsArithmetic()) {
                dp->val.p = (void*) value;
                continue;
            }

            switch (type) {
            case nsXPTType::T_I8:      dp->val.i8  = (int8_t)   value; break;
            case nsXPTType::T_I16:     dp->val.i16 = (int16_t)  value; break;
            case nsXPTType::T_I32:     dp->val.i32 = (int32_t)  value; break;
            case nsXPTType::T_I64:     dp->val.i64 = (int64_t)  value; break;
            case nsXPTType::T_U8:      dp->val.u8  = (uint8_t)  value; break;
            case nsXPTType::T_U16:     dp->val.u16 = (uint16_t) value; break;
            case nsXPTType::T_U32:     dp->val.u32 = (uint32_t) value; break;
            case nsXPTType::T_U64:     dp->val.u64 = (uint64_t) value; break;
            case nsXPTType::T_BOOL:    dp->val.b   = (bool)     value; break;
            case nsXPTType::T_CHAR:    dp->val.c   = (char)     value; break;
            case nsXPTType::T_WCHAR:   dp->val.wc  = (wchar_t)  value; break;

            default:
                NS_ERROR("bad type");
                break;
            }
        }

        nsresult result = self->mOuter->CallMethod((uint16_t) methodIndex, info,
                                                   paramBuffer);

        return result;
    }