Skip to content

Commit

Permalink
refactor: declare DEFAULT_OPT as a global variable
Browse files Browse the repository at this point in the history
Use static variable in header files is not a good idea, there can be multiple copies after
including.
  • Loading branch information
tonytonyjan committed Sep 29, 2017
1 parent ba2b936 commit 554f4cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ext/jaro_winkler/jaro.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#define SWAP(x, y) do{ __typeof__(x) SWAP = x; x = y; y = SWAP; }while(0)

const LibJaroOption DEFAULT_OPT = {.weight = DEFAULT_WEIGHT, .threshold = DEFAULT_THRESHOLD, .ignore_case = 0, .adj_table = 0};

double jaro_distance_from_codes(uint64_t *codes1, size_t len1, uint64_t *codes2, size_t len2, LibJaroOption *opt);
double jaro_winkler_distance_from_codes(uint64_t *codes1, size_t len1, uint64_t *codes2, size_t len2, LibJaroOption *opt);

Expand Down
2 changes: 1 addition & 1 deletion ext/jaro_winkler/jaro.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ typedef struct LibJaroOption{
} LibJaroOption;


static const LibJaroOption DEFAULT_OPT = {.weight = DEFAULT_WEIGHT, .threshold = DEFAULT_THRESHOLD, .ignore_case = 0, .adj_table = 0};
extern const LibJaroOption DEFAULT_OPT;
double jaro_distance(char *str1, size_t len1, char *str2, size_t len2, LibJaroOption *opt);
double jaro_winkler_distance(char *str1, size_t len1, char *str2, size_t len2, LibJaroOption *opt);

0 comments on commit 554f4cf

Please sign in to comment.