Commits

Shlomi Fish committed 8f72729

Add some initial likely()s and unlikely()s.

git-svn-id: file:///home/shlomif/Backup/svn-dumps/google-code/svnsync-repos/fc-solve/branches/likely-addition@2895 e7e8a897-7ba4-4ee7-b36f-f4c66519b19a

Comments (0)

Files changed (3)

fc-solve/source/freecell.c

 #include "freecell.h"
 
 #include "inline.h"
+#include "likely.h"
 
 #ifndef min
 #define min(a,b) (((a)<(b))?(a):(b))
 #endif
 
             /* Skip if it's a King - nothing to put it on. */
-            if (fcs_card_card_num(card) == 13)
+            if (unlikely(fcs_card_card_num(card) == 13))
             {
                 continue;
             }
                     freestacks_to_fill = 0;
                 }
 
-                if ((num_cards_to_relocate == 0) &&
+                if (unlikely((num_cards_to_relocate == 0) &&
                    (calc_max_sequence_move(num_vacant_freecells-freecells_to_fill, num_vacant_stacks-freestacks_to_fill) >=
-                    seq_end - c + 1))
+                    seq_end - c + 1)))
                 {
                     int cols_indexes[3];
                     sfs_check_state_begin()

fc-solve/source/instance.c

 #include "move_funcs_order.h"
 
 #include "inline.h"
+#include "likely.h"
 
 /*
     General use of this interface:
 #define my_befs_weights soft_thread->method_specific.befs.meth.befs.befs_weights
     for(a=0;a<(sizeof(my_befs_weights)/sizeof(my_befs_weights[0]));a++)
     {
-        if (my_befs_weights[a] < 0)
+        if (unlikely(my_befs_weights[a] < 0))
         {
             my_befs_weights[a] = fc_solve_default_befs_weights[a];
         }
         sum += my_befs_weights[a];
     }
-    if (sum < 1e-6)
+    if (unlikely(sum < 1e-6))
     {
         sum = 1;
     }
         }
         for(;depth<dfs_max_depth;depth++)
         {
-            if (info_ptr->derived_states_list.states)
+            if (likely(info_ptr->derived_states_list.states))
             {
                 free(info_ptr->derived_states_list.states);
                 free(info_ptr->derived_states_random_indexes);
 
     free(soft_thread->tests_order.tests);
 
-    if (soft_thread->name != NULL)
+    if (likely(soft_thread->name != NULL))
     {
         free(soft_thread->name);
     }
 
 static GCC_INLINE void free_instance_hard_thread_callback(fc_solve_hard_thread_t * hard_thread)
 {
-    if (hard_thread->prelude_as_string)
+    if (likely(hard_thread->prelude_as_string))
     {
         free (hard_thread->prelude_as_string);
     }
-    if (hard_thread->prelude)
+    if (likely(hard_thread->prelude))
     {
         free (hard_thread->prelude);
     }
 
     free(hard_thread->soft_threads);
 
-    if (hard_thread->allocator.packs)
+    if (likely(hard_thread->allocator.packs))
     {
         fc_solve_compact_allocator_finish(&(hard_thread->allocator));
         hard_thread->allocator.packs = NULL;

fc-solve/source/scans.c

 
 #include "check_limits.h"
 #include "inline.h"
+#include "likely.h"
 
 void fc_solve_increase_dfs_max_depth(
     fc_solve_soft_thread_t * soft_thread
             break;
     }
 
-    if (! *positions_by_rank_location)
+    if (unlikely(! *positions_by_rank_location))
     {
         char * positions_by_rank;
 #if (!(defined(HARD_CODED_NUM_STACKS) && defined(HARD_CODED_NUM_DECKS)))
                     dest_col = fcs_state_get_col(*(ptr_state_key), ds);
                     top_card_idx = fcs_col_len(dest_col);
 
-                    if ((top_card_idx--) == 0)
+                    if (unlikely((top_card_idx--) == 0))
                     {
                         continue;
                     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.