Changeset 1840 in kBuild for trunk/src/kmk
- Timestamp:
- Oct 11, 2008 7:59:17 PM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/make.h
r1835 r1840 150 150 #endif 151 151 152 #if defined(KMK) || defined(CONFIG_WITH_VALUE_LENGTH) 152 #if defined(KMK) || defined(CONFIG_WITH_VALUE_LENGTH) || defined (VARIABLE_HASH) 153 153 # ifdef _MSC_VER 154 154 # define MY_INLINE _inline static … … 170 170 # else 171 171 # define MY_ASSERT_MSG(expr, printfargs) do { } while (0) 172 # endif 173 174 # ifdef __GNUC__ 175 # define MY_PREDICT_TRUE(expr) __builtin_expect(!!(expr), 1) 176 # define MY_PREDICT_FALSE(expr) __builtin_expect(!!(expr), 0) 177 # else 178 # define MY_PREDICT_TRUE(expr) (expr) 179 # define MY_PREDICT_FALSE(expr) (expr) 172 180 # endif 173 181 #endif -
trunk/src/kmk/misc.c
r1839 r1840 551 551 const char *p = *ptr; 552 552 const char *e; 553 unsigned char ch;554 553 555 554 /* skip blanks */ 556 555 for (;;) 557 556 { 558 ch = *p; 559 if (!isblank(ch)) 560 break; 561 ch = p[1]; 562 if (!isblank(ch)) 557 unsigned char ch0, ch1, ch2, ch3; 558 559 ch0 = *p; 560 if (MY_PREDICT_FALSE(!isblank(ch0))) 563 561 { 562 if (!ch0) 563 return NULL; 564 break; 565 } 566 ch1 = p[1]; 567 if (MY_PREDICT_FALSE(!isblank(ch1))) 568 { 569 if (!ch1) 570 return NULL; 564 571 p += 1; 565 572 break; 566 573 } 567 ch = p[2];568 if ( !isblank(ch))574 ch2 = p[2]; 575 if (MY_PREDICT_FALSE(!isblank(ch2))) 569 576 { 577 if (!ch2) 578 return NULL; 570 579 p += 2; 571 580 break; 572 581 } 573 ch = p[3];574 if ( !isblank(ch))582 ch3 = p[3]; 583 if (MY_PREDICT_TRUE(!isblank(ch3))) 575 584 { 585 if (!ch3) 586 return NULL; 576 587 p += 3; 577 588 break; … … 579 590 p += 4; 580 591 } 581 if (!ch)582 {583 *ptr = p;584 return 0;585 }586 592 587 593 /* skip ahead until EOS or blanks. */ … … 589 595 for (;;) 590 596 { 591 ch = *e; 592 if (isblank(ch) || ch == '\0') 597 unsigned char ch0, ch1, ch2, ch3; 598 599 ch0 = *e; 600 if (MY_PREDICT_FALSE(isblank(ch0) || ch0 == '\0')) 593 601 break; 594 ch = e[1];595 if ( isblank(ch) || ch == '\0')602 ch1 = e[1]; 603 if (MY_PREDICT_FALSE(isblank(ch1) || ch1 == '\0')) 596 604 { 597 605 e += 1; 598 606 break; 599 607 } 600 ch = e[2];601 if ( isblank(ch) || ch == '\0')608 ch2 = e[2]; 609 if (MY_PREDICT_FALSE(isblank(ch2) || ch2 == '\0')) 602 610 { 603 611 e += 2; 604 612 break; 605 613 } 606 ch = e[3];607 if ( isblank(ch) || ch == '\0')614 ch3 = e[3]; 615 if (MY_PREDICT_FALSE(isblank(ch3) || ch3 == '\0')) 608 616 { 609 617 e += 3; -
trunk/src/kmk/variable.c
r1829 r1840 352 352 #else /* VARIABLE_HASH */ 353 353 354 # ifdef __GNUC__355 # define PREDICT_TRUE(expr) __builtin_expect(!!(expr), 1)356 # define PREDICT_FALSE(expr) __builtin_expect(!!(expr), 0)357 # else358 # define PREDICT_TRUE(expr) (expr)359 # define PREDICT_FALSE(expr) (expr)360 # endif361 362 354 inline static int 363 355 variable_hash_cmp_2_memcmp (const char *xs, const char *ys, unsigned int length) … … 446 438 result = *(int32_t*)xs - *(int32_t*)ys; 447 439 result |= *(int32_t*)(xs + 4) - *(int32_t*)(ys + 4); 448 if ( PREDICT_FALSE(result))440 if (MY_PREDICT_FALSE(result)) 449 441 return result; 450 442 xs += 8; … … 514 506 result |= xs[4] - ys[4]; 515 507 #endif 516 if ( PREDICT_FALSE(result))508 if (MY_PREDICT_FALSE(result)) 517 509 return result; 518 510 xs += 8; … … 559 551 result = (x->hash1 - y->hash1) 560 552 | (x->length - y->length); 561 if ( PREDICT_TRUE(result))553 if (MY_PREDICT_TRUE(result)) 562 554 return result; 563 555
Note:
See TracChangeset
for help on using the changeset viewer.