# Global Metrics

path: .metrics.cognitive.sum
old: 7.0
new: 68.0
path: .metrics.cognitive.average
old: 1.1666666666666667
new: 34.0
path: .metrics.nexits.average
old: 1.5
new: 0.5
path: .metrics.nexits.sum
old: 9.0
new: 1.0
path: .metrics.nom.functions
old: 6.0
new: 2.0
path: .metrics.nom.total
old: 6.0
new: 2.0
path: .metrics.loc.blank
old: 28.0
new: 36.0
path: .metrics.loc.lloc
old: 21.0
new: 84.0
path: .metrics.loc.ploc
old: 117.0
new: 134.0
path: .metrics.loc.cloc
old: 52.0
new: 18.0
path: .metrics.loc.sloc
old: 197.0
new: 188.0
path: .metrics.mi.mi_visual_studio
old: 21.842692567638434
new: 19.7499984765397
path: .metrics.mi.mi_original
old: 37.35100429066172
new: 33.77249739488289
path: .metrics.mi.mi_sei
old: 15.743697648282236
new: -0.35311552929887213
path: .metrics.nargs.sum
old: 20.0
new: 5.0
path: .metrics.nargs.average
old: 3.3333333333333335
new: 2.5
path: .metrics.cyclomatic.sum
old: 18.0
new: 35.0
path: .metrics.cyclomatic.average
old: 1.8
new: 11.666666666666666
path: .metrics.halstead.volume
old: 4658.1072798775485
new: 5055.82687480259
path: .metrics.halstead.length
old: 678.0
new: 753.0
path: .metrics.halstead.bugs
old: 0.9875943159678576
new: 1.223081685223542
path: .metrics.halstead.effort
old: 161268.57730018167
new: 222261.92761151388
path: .metrics.halstead.n1
old: 22.0
new: 27.0
path: .metrics.halstead.N1
old: 379.0
new: 499.0
path: .metrics.halstead.estimated_program_length
old: 722.2437784014606
new: 618.6433356296691
path: .metrics.halstead.time
old: 8959.365405565648
new: 12347.884867306326
path: .metrics.halstead.purity_ratio
old: 1.065256310326638
new: 0.8215714948601183
path: .metrics.halstead.n2
old: 95.0
new: 78.0
path: .metrics.halstead.N2
old: 299.0
new: 254.0
path: .metrics.halstead.vocabulary
old: 117.0
new: 105.0
path: .metrics.halstead.difficulty
old: 34.62105263157895
new: 43.96153846153846
path: .metrics.halstead.level
old: 0.028884159318941928
new: 0.022747156605424323

# Spaces Data

## Minimal test - lines (14, 172)

path: .spaces[0].metrics.nargs.sum
old: 20.0
new: 5.0
path: .spaces[0].metrics.nargs.average
old: 3.3333333333333335
new: 5.0
path: .spaces[0].metrics.nom.functions
old: 6.0
new: 1.0
path: .spaces[0].metrics.nom.total
old: 6.0
new: 1.0
path: .spaces[0].metrics.cognitive.average
old: 1.1666666666666667
new: 68.0
path: .spaces[0].metrics.cognitive.sum
old: 7.0
new: 68.0
path: .spaces[0].metrics.cyclomatic.sum
old: 17.0
new: 33.0
path: .spaces[0].metrics.cyclomatic.average
old: 1.8888888888888888
new: 33.0
path: .spaces[0].metrics.loc.cloc
old: 44.0
new: 9.0
path: .spaces[0].metrics.loc.lloc
old: 21.0
new: 84.0
path: .spaces[0].metrics.loc.sloc
old: 181.0
new: 159.0
path: .spaces[0].metrics.loc.blank
old: 26.0
new: 25.0
path: .spaces[0].metrics.loc.ploc
old: 111.0
new: 125.0
path: .spaces[0].metrics.mi.mi_visual_studio
old: 22.840514101509303
new: 21.70458017703985
path: .spaces[0].metrics.mi.mi_original
old: 39.05727911358092
new: 37.11483210273815
path: .spaces[0].metrics.mi.mi_sei
old: 16.96219730228463
new: -0.7809909201345455
path: .spaces[0].metrics.halstead.purity_ratio
old: 1.003642516318497
new: 0.7635324433016839
path: .spaces[0].metrics.halstead.estimated_program_length
old: 674.44777096603
new: 565.0140080432461
path: .spaces[0].metrics.halstead.vocabulary
old: 111.0
new: 98.0
path: .spaces[0].metrics.halstead.bugs
old: 1.004168383524628
new: 1.2475197849865918
path: .spaces[0].metrics.halstead.volume
old: 4565.847462187271
new: 4894.885284645255
path: .spaces[0].metrics.halstead.level
old: 0.027614024201054917
new: 0.021379102679915687
path: .spaces[0].metrics.halstead.difficulty
old: 36.21348314606742
new: 46.774647887323944
path: .spaces[0].metrics.halstead.effort
old: 165345.24011943344
new: 228956.53563812523
path: .spaces[0].metrics.halstead.n2
old: 89.0
new: 71.0
path: .spaces[0].metrics.halstead.n1
old: 22.0
new: 27.0
path: .spaces[0].metrics.halstead.time
old: 9185.846673301858
new: 12719.807535451402
path: .spaces[0].metrics.halstead.N1
old: 379.0
new: 494.0
path: .spaces[0].metrics.halstead.N2
old: 293.0
new: 246.0
path: .spaces[0].metrics.halstead.length
old: 672.0
new: 740.0
path: .spaces[0].metrics.nexits.average
old: 1.5
new: 1.0
path: .spaces[0].metrics.nexits.sum
old: 9.0
new: 1.0

### Code

    extern "C" nsresult
    PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args,
                       uint64_t *gprData, double *fprData)
    {
    //
    // "this" pointer is first parameter, so parameter count is 3.
    //
    #define PARAM_GPR_COUNT   3
    #define PARAM_FPR_COUNT   3

        nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
        const nsXPTMethodInfo* info = nullptr;
        uint8_t paramCount;
        uint8_t i;

        NS_ASSERTION(self,"no self");

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

        paramCount = info->GetParamCount();

        const uint8_t indexOfJSContext = info->IndexOfJSContext();

        uint64_t* ap = args;
        uint32_t iCount = 0;

        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 (iCount < PARAM_GPR_COUNT)
                    iCount++;
                else
                    ap++;
            }

            if(param.IsOut() || !type.IsArithmetic())
            {
                if (iCount < PARAM_GPR_COUNT)
                    dp->val.p = (void*)gprData[iCount++];
                else
                    dp->val.p = (void*)*ap++;

                continue;
            }
            // else
            switch(type)
            {
            case nsXPTType::T_I8:
               if (iCount < PARAM_GPR_COUNT)
                  dp->val.i8  = (int8_t)gprData[iCount++];
               else
                  dp->val.i8  = *((int8_t*)ap++);
               break;

            case nsXPTType::T_I16:
                if (iCount < PARAM_GPR_COUNT)
                   dp->val.i16  = (int16_t)gprData[iCount++];
                else
                   dp->val.i16  = *((int16_t*)ap++);
                break;

            case nsXPTType::T_I32:
                if (iCount < PARAM_GPR_COUNT)
                   dp->val.i32  = (int32_t)gprData[iCount++];
                else
                   dp->val.i32  = *((int32_t*)ap++);
                break;

            case nsXPTType::T_I64:
                if (iCount < PARAM_GPR_COUNT)
                   dp->val.i64  = (int64_t)gprData[iCount++];
                else
                   dp->val.i64  = *((int64_t*)ap++);
                break;

            case nsXPTType::T_U8:
                if (iCount < PARAM_GPR_COUNT)
                   dp->val.u8  = (uint8_t)gprData[iCount++];
                else
                   dp->val.u8  = *((uint8_t*)ap++);
                break;

            case nsXPTType::T_U16:
                if (iCount < PARAM_GPR_COUNT)
                   dp->val.u16  = (uint16_t)gprData[iCount++];
                else
                    dp->val.u16  = *((uint16_t*)ap++);
                break;

            case nsXPTType::T_U32:
                if (iCount < PARAM_GPR_COUNT)
                   dp->val.u32  = (uint32_t)gprData[iCount++];
                else
                   dp->val.u32  = *((uint32_t*)ap++);
                break;

            case nsXPTType::T_U64:
                if (iCount < PARAM_GPR_COUNT)
                   dp->val.u64  = (uint64_t)gprData[iCount++];
                else
                   dp->val.u64  = *((uint64_t*)ap++);
                break;

            case nsXPTType::T_FLOAT:
                 if (iCount < PARAM_FPR_COUNT)
                    // The value in xmm register is already prepared to
                    // be retrieved as a float. Therefore, we pass the
                    // value verbatim, as a double without conversion.
                    dp->val.d  = (double)fprData[iCount++];
                 else
                    dp->val.f  = *((float*)ap++);
                 break;

            case nsXPTType::T_DOUBLE:
                  if (iCount < PARAM_FPR_COUNT)
                     dp->val.d  = (double)fprData[iCount++];
                  else
                     dp->val.d  = *((double*)ap++);
                  break;

            case nsXPTType::T_BOOL:
               if (iCount < PARAM_GPR_COUNT)
                  // We need the cast to uint8_t to remove garbage on upper 56-bit
                  // at first.
                  dp->val.b  = (bool)(uint8_t)gprData[iCount++];
               else
                  dp->val.b  = *((bool*)ap++);
               break;

            case nsXPTType::T_CHAR:
               if (iCount < PARAM_GPR_COUNT)
                  dp->val.c  = (char)gprData[iCount++];
               else
                  dp->val.c  = *((char*)ap++);
               break;

            case nsXPTType::T_WCHAR:
               if (iCount < PARAM_GPR_COUNT)
                  dp->val.wc  = (wchar_t)gprData[iCount++];
               else
                  dp->val.wc  = *((wchar_t*)ap++);
               break;

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

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

        return result;
    }