Skip to content

Commit

Permalink
improve xxhash
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Nov 15, 2024
1 parent 2a8211a commit ad83244
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/src/xmake/hash/xxhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tb_int_t xm_hash_xxhash(lua_State* lua)
if (mode != 64 && mode != 128)
{
lua_pushnil(lua);
lua_pushfstring(lua, "invalid mode(%d))!", (tb_int_t)mode);
lua_pushfstring(lua, "invalid mode(%d)!", (tb_int_t)mode);
return 2;
}

Expand All @@ -65,7 +65,7 @@ tb_int_t xm_hash_xxhash(lua_State* lua)
tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t));

// compuate hash
tb_byte_t const* buffer;
tb_byte_t const* buffer = tb_null;
XXH64_hash_t value64;
XXH128_hash_t value128;
if (mode == 64)
Expand All @@ -78,6 +78,12 @@ tb_int_t xm_hash_xxhash(lua_State* lua)
value128 = XM_XXH3_128bits(data, size);
buffer = (tb_byte_t const*)&value128;
}
if (!buffer)
{
lua_pushnil(lua);
lua_pushfstring(lua, "empty buffer!");
return 2;
}

// make xxhash string
tb_size_t i = 0;
Expand Down

0 comments on commit ad83244

Please sign in to comment.