What is the reason for these PMD rules?

后端 未结 6 802
滥情空心
滥情空心 2020-12-01 04:41

DataflowAnomalyAnalysis: Found \'DD\'-anomaly for variable \'variable\' (lines \'n1\'-\'n2\').

DataflowAnomalyAnalysis: Found \'DU\'-anomaly

6条回答
  •  执笔经年
    2020-12-01 05:09

    AvoidUsingShortType: Do not use the short type

    • List item

      short is 16 bit, 2's compliment in java

    • a short mathmatical operaion with anything in the Integer family outside of another short will require a runtime sign extension conversion to the larger size. operating against a floating point requires sign extension and a non-trivial conversion to IEEE-754.

    • can't find proof, but with a 32 bit or 64 bit register, you're no longer saving on 'processor instructions' at the bytecode level. You're parking a compact car in a a semi-trailer's parking spot as far as the processor register is concerned.

    • If your are optimizing your project at the byte code level, wow. just wow. ;P

    • I agree on the design side of ignoring this pmd warning, just weigh accurately describing your object with a 'short' versus the incurred performance conversions.

    • in my opinion, the incurred performance hits are miniscule on most machines. ignore the error.

提交回复
热议问题