Fossil SCM

(experiment) Use d_type field of dirent structure for speedup.

jan.nijtmans 2014-02-20 15:19 UTC trunk
Commit 0c7834c77b30469ab2587eeff9797b3ec8134fb4
1 file changed +20
+20
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486486
blob_appendf(pPath, "/%s", zUtf8);
487487
zPath = blob_str(pPath);
488488
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489489
glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490490
/* do nothing */
491
+#ifdef _DIRENT_HAVE_D_TYPE
492
+ }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isdir(zPath)==1)
493
+ : (pEntry->d_type==DT_DIR) ){
494
+#else
491495
}else if( file_wd_isdir(zPath)==1 ){
496
+#endif
492497
if( !vfile_top_of_checkout(zPath) ){
493498
vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
494499
}
500
+#ifdef _DIRENT_HAVE_D_TYPE
501
+ }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isfile_or_link(zPath))
502
+ : (pEntry->d_type==DT_REG||pEntry->d_type==DT_LNK) ){
503
+#else
495504
}else if( file_wd_isfile_or_link(zPath) ){
505
+#endif
496506
if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
497507
db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
498508
db_step(&ins);
499509
db_reset(&ins);
500510
}
@@ -593,11 +603,16 @@
593603
zPath = blob_str(pPath);
594604
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
595605
glob_match(pIgnore2, &zPath[nPrefix+1]) ||
596606
glob_match(pIgnore3, &zPath[nPrefix+1]) ){
597607
/* do nothing */
608
+#ifdef _DIRENT_HAVE_D_TYPE
609
+ }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isdir(zPath)==1)
610
+ : (pEntry->d_type==DT_DIR) ){
611
+#else
598612
}else if( file_wd_isdir(zPath)==1 ){
613
+#endif
599614
if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
600615
char *zSavePath = mprintf("%s", zPath);
601616
int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
602617
pIgnore2, pIgnore3);
603618
db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
605620
db_step(&ins);
606621
db_reset(&ins);
607622
fossil_free(zSavePath);
608623
result += count; /* found X normal files? */
609624
}
625
+#ifdef _DIRENT_HAVE_D_TYPE
626
+ }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isfile_or_link(zPath))
627
+ : (pEntry->d_type==DT_REG||pEntry->d_type==DT_LNK) ){
628
+#else
610629
}else if( file_wd_isfile_or_link(zPath) ){
630
+#endif
611631
db_bind_text(&upd, ":file", zOrigPath);
612632
db_step(&upd);
613633
db_reset(&upd);
614634
result++; /* found 1 normal file */
615635
}
616636
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486 blob_appendf(pPath, "/%s", zUtf8);
487 zPath = blob_str(pPath);
488 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490 /* do nothing */
 
 
 
 
491 }else if( file_wd_isdir(zPath)==1 ){
 
492 if( !vfile_top_of_checkout(zPath) ){
493 vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
494 }
 
 
 
 
495 }else if( file_wd_isfile_or_link(zPath) ){
 
496 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
497 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
498 db_step(&ins);
499 db_reset(&ins);
500 }
@@ -593,11 +603,16 @@
593 zPath = blob_str(pPath);
594 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
595 glob_match(pIgnore2, &zPath[nPrefix+1]) ||
596 glob_match(pIgnore3, &zPath[nPrefix+1]) ){
597 /* do nothing */
 
 
 
 
598 }else if( file_wd_isdir(zPath)==1 ){
 
599 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
600 char *zSavePath = mprintf("%s", zPath);
601 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
602 pIgnore2, pIgnore3);
603 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
605 db_step(&ins);
606 db_reset(&ins);
607 fossil_free(zSavePath);
608 result += count; /* found X normal files? */
609 }
 
 
 
 
610 }else if( file_wd_isfile_or_link(zPath) ){
 
611 db_bind_text(&upd, ":file", zOrigPath);
612 db_step(&upd);
613 db_reset(&upd);
614 result++; /* found 1 normal file */
615 }
616
--- src/vfile.c
+++ src/vfile.c
@@ -486,15 +486,25 @@
486 blob_appendf(pPath, "/%s", zUtf8);
487 zPath = blob_str(pPath);
488 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
489 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
490 /* do nothing */
491 #ifdef _DIRENT_HAVE_D_TYPE
492 }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isdir(zPath)==1)
493 : (pEntry->d_type==DT_DIR) ){
494 #else
495 }else if( file_wd_isdir(zPath)==1 ){
496 #endif
497 if( !vfile_top_of_checkout(zPath) ){
498 vfile_scan(pPath, nPrefix, scanFlags, pIgnore1, pIgnore2);
499 }
500 #ifdef _DIRENT_HAVE_D_TYPE
501 }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isfile_or_link(zPath))
502 : (pEntry->d_type==DT_REG||pEntry->d_type==DT_LNK) ){
503 #else
504 }else if( file_wd_isfile_or_link(zPath) ){
505 #endif
506 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
507 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
508 db_step(&ins);
509 db_reset(&ins);
510 }
@@ -593,11 +603,16 @@
603 zPath = blob_str(pPath);
604 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
605 glob_match(pIgnore2, &zPath[nPrefix+1]) ||
606 glob_match(pIgnore3, &zPath[nPrefix+1]) ){
607 /* do nothing */
608 #ifdef _DIRENT_HAVE_D_TYPE
609 }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isdir(zPath)==1)
610 : (pEntry->d_type==DT_DIR) ){
611 #else
612 }else if( file_wd_isdir(zPath)==1 ){
613 #endif
614 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
615 char *zSavePath = mprintf("%s", zPath);
616 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
617 pIgnore2, pIgnore3);
618 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
@@ -605,11 +620,16 @@
620 db_step(&ins);
621 db_reset(&ins);
622 fossil_free(zSavePath);
623 result += count; /* found X normal files? */
624 }
625 #ifdef _DIRENT_HAVE_D_TYPE
626 }else if( (pEntry->d_type==DT_UNKNOWN) ? (file_wd_isfile_or_link(zPath))
627 : (pEntry->d_type==DT_REG||pEntry->d_type==DT_LNK) ){
628 #else
629 }else if( file_wd_isfile_or_link(zPath) ){
630 #endif
631 db_bind_text(&upd, ":file", zOrigPath);
632 db_step(&upd);
633 db_reset(&upd);
634 result++; /* found 1 normal file */
635 }
636

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button