Skip to content

Commit

Permalink
Use of memcmp instead of strcmp for string_equal_p
Browse files Browse the repository at this point in the history
  • Loading branch information
P-p-H-d committed Jun 12, 2024
1 parent 4ba55dc commit 3f102c2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion m-string.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ m_string_equal_p(const m_string_t v1, const m_string_t v2)
M_ASSERT(v1 != NULL);
M_ASSERT(v2 != NULL);
/* Optimization: both strings shall have at least the same size */
return m_string_size(v1) == m_string_size(v2) && m_string_cmp(v1, v2) == 0;
return m_string_size(v1) == m_string_size(v2)
&& memcmp(m_string_get_cstr(v1), m_string_get_cstr(v2), m_string_size(v1)) == 0;
}

/* Test if the string is equal to the C string
Expand Down

0 comments on commit 3f102c2

Please sign in to comment.