@@ -683,50 +683,19 @@ impl SimilarImages {
683
683
mem:: swap ( & mut all_hashed_images, & mut self . image_hashes ) ;
684
684
685
685
let all_hashes: Vec < _ > = all_hashed_images. keys ( ) . collect ( ) ;
686
- let mut already_used_hashes: HashSet < _ > = Default :: default ( ) ; // List of already user hashes
687
-
688
- for ( hash, vec_file_entry) in all_hashed_images. clone ( ) {
689
- // There exists 2 or more images with same hash
690
- if vec_file_entry. len ( ) >= 2 {
691
- already_used_hashes. insert ( hash. clone ( ) ) ;
692
- collected_similar_images. insert ( hash, vec_file_entry) ;
693
- } else {
694
- self . bktree . add ( hash. clone ( ) ) ;
695
- }
696
- }
697
-
698
- //// PROGRESS THREAD START
699
- let check_was_stopped = AtomicBool :: new ( false ) ; // Used for breaking from GUI and ending check thread
700
- let progress_thread_run = Arc :: new ( AtomicBool :: new ( true ) ) ;
701
-
702
- let atomic_mode_counter = Arc :: new ( AtomicUsize :: new ( 0 ) ) ;
703
686
704
- let progress_thread_handle = if let Some ( progress_sender) = progress_sender {
705
- let progress_send = progress_sender. clone ( ) ;
706
- let progress_thread_run = progress_thread_run. clone ( ) ;
707
- let atomic_mode_counter = atomic_mode_counter. clone ( ) ;
708
- let all_hashes_number = all_hashes. len ( ) ;
709
- thread:: spawn ( move || loop {
710
- progress_send
711
- . unbounded_send ( ProgressData {
712
- current_stage : 2 ,
713
- max_stage : 3 ,
714
- images_checked : atomic_mode_counter. load ( Ordering :: Relaxed ) as usize ,
715
- images_to_check : all_hashes_number,
716
- } )
717
- . unwrap ( ) ;
718
- if !progress_thread_run. load ( Ordering :: Relaxed ) {
719
- break ;
687
+ // Checking entries with tolerance 0 is really easy and fast, because only entries with same hashes needs to be checked
688
+ if tolerance == 0 {
689
+ for ( hash, vec_file_entry) in all_hashed_images. clone ( ) {
690
+ if vec_file_entry. len ( ) >= 2 {
691
+ collected_similar_images. insert ( hash, vec_file_entry) ;
720
692
}
721
- sleep ( Duration :: from_millis ( LOOP_DURATION as u64 ) ) ;
722
- } )
693
+ }
723
694
} else {
724
- thread:: spawn ( || { } )
725
- } ;
726
- //// PROGRESS THREAD END
727
- let mut timer = SystemTime :: now ( ) ;
695
+ for hash in & all_hashes {
696
+ self . bktree . add ( hash. to_vec ( ) ) ;
697
+ }
728
698
729
- if tolerance > 0 {
730
699
let number_of_processors = num_cpus:: get ( ) ;
731
700
let chunks = all_hashes. chunks ( all_hashes. len ( ) / number_of_processors) ;
732
701
@@ -790,13 +759,12 @@ impl SimilarImages {
790
759
}
791
760
}
792
761
762
+ #[ cfg( debug_assertions) ]
793
763
debug_check_for_duplicated_things ( hashes_parents. clone ( ) , hashes_similarity. clone ( ) , all_hashed_images. clone ( ) , "BEFORE" ) ;
794
764
795
765
( hashes_parents, hashes_similarity)
796
766
} )
797
767
. collect ( ) ;
798
- Common :: print_time ( timer, SystemTime :: now ( ) , "CHECKING IN PARRAREL" . to_string ( ) ) ;
799
- timer = SystemTime :: now ( ) ;
800
768
801
769
{
802
770
let mut new_hashes_parents: HashMap < & Vec < u8 > , u32 > = Default :: default ( ) ;
@@ -847,9 +815,8 @@ impl SimilarImages {
847
815
}
848
816
}
849
817
}
850
- Common :: print_time ( timer, SystemTime :: now ( ) , "Connecting results" . to_string ( ) ) ;
851
- timer = SystemTime :: now ( ) ;
852
818
819
+ #[ cfg( debug_assertions) ]
853
820
debug_check_for_duplicated_things ( new_hashes_parents. clone ( ) , new_hashes_similarity. clone ( ) , all_hashed_images. clone ( ) , "LATTER" ) ;
854
821
855
822
// Collecting results
@@ -868,12 +835,11 @@ impl SimilarImages {
868
835
}
869
836
collected_similar_images. get_mut ( parent_hash) . unwrap ( ) . append ( & mut vec_fe) ;
870
837
}
871
- Common :: print_time ( timer, SystemTime :: now ( ) , "Creating entries" . to_string ( ) ) ;
872
838
}
873
839
}
874
840
875
841
// Validating if group contains duplicated results
876
- // #[cfg(debug_assertions)]
842
+ #[ cfg( debug_assertions) ]
877
843
{
878
844
let mut result_hashset: HashSet < String > = Default :: default ( ) ;
879
845
let mut found = false ;
0 commit comments