How would you make this switch statement as fast as possible?

后端 未结 21 2078
别那么骄傲
别那么骄傲 2021-01-30 04:17

2009-12-04 UPDATE: For profiling results on a number of the suggestions posted here, see below!


The Question

Consider the following very

21条回答
  •  太阳男子
    2021-01-30 05:04

    With a valid input could use

    if (ActivCode.Length == 0)
        return MarketDataExchange.NBBO;
    
    if (ActivCode.Length == 1)
        return (MarketDataExchange) (ActivCode[0]);
    
    return (MarketDataExchange) (ActivCode[0] | ActivCode[1] << 8);
    

提交回复
热议问题