Shlomi Fish avatar Shlomi Fish committed 6ce8d69

More consting and JIT compilation.

Comments (0)

Files changed (2)

fc-solve/source/fcs_hash.c

 
   */
 static GCC_INLINE void fc_solve_hash_rehash(
-    fc_solve_hash_t * hash
+    fc_solve_hash_t * const hash
     )
 {
-    int old_size, new_size, new_size_bitmask;
-    int i;
-    fc_solve_hash_symlink_item_t * item, * next_item;
-    int place;
-    fc_solve_hash_symlink_t * new_entries;
+    const int old_size = hash->size;
 
-    old_size = hash->size;
-
-    new_size = old_size << 1;
+    const int new_size = old_size << 1;
 
     /* Check for overflow. */
     if (new_size < old_size)
         return;
     }
 
-    new_size_bitmask = new_size - 1;
+    const int new_size_bitmask = new_size - 1;
 
-    new_entries = calloc(new_size, sizeof(new_entries[0]));
+    fc_solve_hash_symlink_t * const new_entries = calloc(new_size, sizeof(new_entries[0]));
 
     /* Copy the items to the new hash while not allocating them again */
-    for(i=0;i<old_size;i++)
+    for (int i=0 ; i < old_size ; i++)
     {
-        item = hash->entries[i].first_item;
+        fc_solve_hash_symlink_item_t * item = hash->entries[i].first_item;
         /* traverse the chain item by item */
         while(item != NULL)
         {
             /* The place in the new hash table */
-            place = item->hash_value & new_size_bitmask;
+            const int place = item->hash_value & new_size_bitmask;
 
             /* Store the next item in the linked list in a safe place,
                so we can retrieve it after the assignment */
-            next_item = item->next;
+            fc_solve_hash_symlink_item_t * const next_item = item->next;
             /* It is placed in front of the first element in the chain,
                so it should link to it */
             item->next = new_entries[place].first_item;

fc-solve/source/instance.c

 const double fc_solve_default_befs_weights[FCS_NUM_BEFS_WEIGHTS] = {0.5, 0, 0.3, 0, 0.2, 0};
 
 static GCC_INLINE void normalize_befs_weights(
-    fc_solve_state_weighting_t * weighting
+    fc_solve_state_weighting_t * const weighting
 )
 {
     /* Normalize the Best-First-Search Weights, so the sum of all of them would be 1. */
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.