- const size_t strl = strlen(str);
- const size_t keyl = grp->key_len;
- double sr = strl / keyl;
- if (1 < sr) {
- sr = 1 / sr;
- }
- return ctx->threshold <= sr;
+ const double lstr = (double) strlen(str);
+ const double lkey = (double) grp->key_len;
+ const double lmin = (lstr > lkey) ? lkey : lstr;
+ const double s = sqrt((2 * lmin * lmin) / (1.0 * lstr * lstr + lkey * lkey));
+ return ctx->threshold <= s;