Skip to content

Commit

Permalink
refactor: prefer sizeof(variable) over sizeof(type)
Browse files Browse the repository at this point in the history
Humans make mistakes while compiler do not.
  • Loading branch information
tonytonyjan committed Sep 29, 2017
1 parent 0ac7fce commit 1a37c7e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ext/jaro_winkler/adj_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ AdjMatrix* adj_matrix_new(uint32_t length){
}

void adj_matrix_add(AdjMatrix *matrix, uint64_t x, uint64_t y){
uint32_t h1 = st_hash(&x, sizeof(long long), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH,
h2 = st_hash(&y, sizeof(long long), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH;
uint32_t h1 = st_hash(&x, sizeof(x), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH,
h2 = st_hash(&y, sizeof(y), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH;
Node *new_node = malloc(sizeof(Node)); new_node->x = h1; new_node->y = h2; new_node->next = NULL;
if(matrix->table[h1][h2] == NULL){
matrix->table[h1][h2] = matrix->table[h2][h1] = new_node;
Expand All @@ -38,8 +38,8 @@ void adj_matrix_add(AdjMatrix *matrix, uint64_t x, uint64_t y){
}

char adj_matrix_find(AdjMatrix *matrix, uint64_t x, uint64_t y){
uint32_t h1 = st_hash(&x, sizeof(long long), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH,
h2 = st_hash(&y, sizeof(long long), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH;
uint32_t h1 = st_hash(&x, sizeof(x), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH,
h2 = st_hash(&y, sizeof(y), ADJ_MATRIX_SEED) % ADJ_MATRIX_DEFAULT_LENGTH;
Node *node = matrix->table[h1][h2];
if(node == NULL) return 0;
else{
Expand Down

0 comments on commit 1a37c7e

Please sign in to comment.