title: C++ most optimal conversion
body: <p>Is that most optimal for server (speed) conversion of data ?</p>
  
  <p>Could I change it for better performance ?</p>
  
  <p>This is used in packet parser to set/get packet data.</p>
  
  <pre><code>void Packet::setChar(char val, unsigned int offset)
  {
      raw[offset + 8] = val;
  }
  
  short Packet::getChar(unsigned int offset)
  {
      return raw[offset + 8];
  }
  
  void Packet::setShort(short val, unsigned int offset)
  {
      raw[offset + 8] = val &amp; 0xff;
      raw[offset + 9] = (val &gt;&gt; 8)  &amp; 0xff;
  }
  
  short Packet::getShort(unsigned int offset)
  {
      return (short)((raw[offset + 9]&amp;0xff) &lt;&lt; 8) | (raw[offset + 8]&amp;0xff);
  }
  
  void Packet::setInt(int val, unsigned int offset)
  {
      raw[offset + 8] = val &amp; 0xff;
      raw[offset + 9] = (val &gt;&gt; 8)  &amp; 0xff;
      raw[offset + 10] = (val &gt;&gt; 16) &amp; 0xff;
      raw[offset + 11] = (val &gt;&gt; 24) &amp; 0xff;
  }
  
  int Packet::getInt(unsigned int offset)
  {
      return (int)((raw[offset + 11]&amp;0xff) &lt;&lt; 24) | ((raw[offset + 10]&amp;0xff) &lt;&lt; 16) | ((raw[offset + 9]&amp;0xff) &lt;&lt; 8) | (raw[offset + 8]&amp;0xff);
  }
  </code></pre>
  
  <p>Class defs :</p>
  
  <pre><code>class Packet
  {
      public:
          Packet(unsigned int length);
          Packet(char * raw);
          ///header
  
          void setChar(char val, unsigned int offset);
          short getChar(unsigned int offset);
  
          void setShort(short val, unsigned int offset);
          short getShort(unsigned int offset);
  
          void setInt(int val, unsigned int offset);
          int getInt(unsigned int offset);
  
          void setLong(long long val, unsigned int offset);
          long getLong(unsigned int offset);
  
          char * getRaw();
  
          ~Packet();
      protected:
      private:
          char * raw;
  };
  </code></pre>
  
  <p>@EDIT added class definitions
  Char raw is inirialized with packet (new char).</p>