I have several arrays of fixed length and want to compare them.
struct Foo
{
    /// the data, not necessarily int and not necessarily length 32
    int val[32];
    /// simple way
    inline bool compare1(const NAME_CELL & rhs) const
    {
        for (unsigned int ui = 0; ui < 32; ++ui)
        {
            if (val[ui] != rhs.val[ui])
            {
                return false;
            }
        }
        return true;
    }
    /// compare memory directly instead of using a loop. Is this faster?
    inline bool compare2(const NAME_CELL & rhs) const
    {
        return memcmp(val, rhs.val, 32 * sizeof(int)) == 0;
    }
};
Is compare1 slower, faster or equal to compare2? Is there an even faster way?
 
    