MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / normalize_weight

Function normalize_weight

strings/uca-dump.c:356–395  ·  view source on GitHub ↗

"weight" must be [MY_UCA_MAXWEIGHT_TO_DUMP+1] elements long */

Source from the content-addressed store, hash-verified

354 "weight" must be [MY_UCA_MAXWEIGHT_TO_DUMP+1] elements long
355*/
356static size_t
357normalize_weight(MY_UCA_ITEM *item, size_t level,
358 uint16 *weight, size_t weight_elements)
359{
360 size_t num, i;
361
362 memset(weight, 0, weight_elements * sizeof(*weight));
363
364 /*
365 Copy non-zero weights only. For example:
366
367 [.17A6.0020.0004.00DF][.0000.015F.0004.00DF][.17A6.0020.001F.00DF]
368
369 makes [17A6][0000][17A6] on the primary level
370
371 pack it to [17A6][17A7]
372 */
373
374 for (num= 0, i= 0; i < item->num && i < MY_UCA_MAXWEIGHT_TO_DUMP; i++)
375 {
376 if (item->weight[level][i])
377 {
378 weight[num]= item->weight[level][i];
379#ifdef INVERT_TERTIARY_WEIGHTS
380 if (level == 2)
381 {
382 /*
383 Invert tertiary weights to sort upper case letters
384 before their lower case counterparts.
385 */
386 if (weight[num] >= 0x20)
387 fprintf(stderr, "Tertiary weight is too big: %02X\n", weight[num]);
388 weight[num]= (uint) (0x20) - weight[num];
389 }
390#endif
391 num++;
392 }
393 }
394 return num;
395}
396
397
398static void

Callers 2

print_one_pageFunction · 0.85
print_contractionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected