List:Commits« Previous MessageNext Message »
From:Patrick Galbraith Date:January 4 2006 2:12am
Subject:bk commit into 5.1 tree (patg:1.2020)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of patg. When patg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2020 06/01/03 18:11:56 patg@stripped +1 -0
  WL# 2682
  
  Modifications for performance - "for" loops to "do {...} while".

  sql/ha_partition.cc
    1.26 06/01/03 18:11:50 patg@stripped +42 -35
    WL# 2682
    
    Changed various "for" loops do "do {...} while" loops per Mikael's suggestion.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	patg
# Host:	govinda.site
# Root:	/home/patg/mysql-build/mysql-5.1-wl2682

--- 1.25/sql/ha_partition.cc	2005-12-31 15:28:06 -08:00
+++ 1.26/sql/ha_partition.cc	2006-01-03 18:11:50 -08:00
@@ -1437,15 +1437,16 @@
 
 int ha_partition::delete_all_rows()
 {
-  int i= 0;
   int error;
+  handler **file;
   DBUG_ENTER("ha_partition::delete_all_rows");
-  for (i= 0; i < (int) m_part_info->no_parts; i++)
+  file= m_file;
+  do
   {
-    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-      if ((error= m_file[i]->delete_all_rows()))
+    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+      if ((error= (*file)->delete_all_rows()))
         DBUG_RETURN(error);
-  }
+  } while (*(++file));
   DBUG_RETURN(0);
 }
 
@@ -1455,7 +1456,7 @@
 
 void ha_partition::start_bulk_insert(ha_rows rows)
 {
-  int i= 0;
+  handler **file;
   DBUG_ENTER("ha_partition::start_bulk_insert");
   if (!rows)
   {
@@ -1463,28 +1464,31 @@
     DBUG_VOID_RETURN;
   }
   rows= rows/m_tot_parts + 1;
-  for (i= 0; i < (int) m_part_info->no_parts; i++)
+  file= m_file;
+  do
   {
-    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-      m_file[i]->start_bulk_insert(rows);
-  }
+    if (_bitmap_is_set(&(m_part_info->used_partitions),(file - m_file)))
+      (*file)->start_bulk_insert(rows);
+  } while (*(++file));
   DBUG_VOID_RETURN;
 }
 
 
 int ha_partition::end_bulk_insert()
 {
-  int i= 0;
   int error= 0;
+  handler **file;
   DBUG_ENTER("ha_partition::end_bulk_insert");
 
-  for (i= 0; i < (int) m_part_info->no_parts; i++)
+  file= m_file;
+  do
   {
     int tmp;
+    int i= file - m_file;
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-      if ((tmp= m_file[i]->end_bulk_insert()))
+      if ((tmp= (*file)->end_bulk_insert()))
         error= tmp;
-  }
+  } while (*(++file));
   DBUG_RETURN(error);
 }
 
@@ -1595,11 +1599,11 @@
     case 0:
       int i=0;
       file= m_file;
-      for (i= 0; i < m_part_info->no_parts; i++)
+      do
       {
-        if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-          m_file[i]->ha_rnd_end();
-      }
+        if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+          (*file)->ha_rnd_end();
+      } while (*(++file));
       break;
   }
   //m_part_spec.start_part= NO_CURRENT_PART_ID;
@@ -1798,16 +1802,16 @@
   m_curr_key_info= table->key_info+inx;
   include_partition_fields_in_used_fields();
   file= m_file;
-  for (i= 0; i < m_part_info->no_parts; i++)
+  do
   {
     /* TODO RONM: Change to index_init() when code is stable */
-    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-      if ((error= m_file[i]->ha_index_init(inx, sorted)))
+    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+      if ((error= (*file)->ha_index_init(inx, sorted)))
       {
         DBUG_ASSERT(0);                           // Should never happen
         break;
       }
-  }
+  } while (*(++file));
   DBUG_RETURN(error);
 }
 
@@ -1827,14 +1831,14 @@
   active_index= MAX_KEY;
   m_part_spec.start_part= NO_CURRENT_PART_ID;
   file= m_file;
-  for (i= 0; i < m_part_info->no_parts; i++)
+  do
   {
     int tmp;
     /* TODO RONM: Change to index_init() when code is stable */
-    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-      if ((tmp= m_file[i]->ha_index_end()))
+    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+      if ((tmp= (*file)->ha_index_end()))
         error= tmp;
-  }
+  } while (*(++file));
   DBUG_RETURN(error);
 }
 
@@ -2261,7 +2265,6 @@
     DBUG_RETURN(0);
   }
 
-  //for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
   DBUG_PRINT("info", ("current_partition_index %d", current_partition_index));
   for (i= current_partition_index; i <= m_part_spec.end_part; i++)
   {
@@ -2993,6 +2996,7 @@
   file= m_file;
   do
   {
+    DBUG_PRINT("info", ("file iterator %d", (file - m_file) ));
     if ((tmp= (*file)->reset()))
       result= tmp;
   } while (*(++file));
@@ -3114,36 +3118,39 @@
 ha_rows ha_partition::records_in_range(uint inx, key_range *min_key,
 				       key_range *max_key)
 {
-  int i= 0;
+  handler **file;
   ha_rows in_range= 0;
   DBUG_ENTER("ha_partition::records_in_range");
 
-  for (i= 0; i < (int) m_part_info->no_parts; i++)
+  file= m_file;
+  do
   {
+    int i= file - m_file;
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
-      in_range+= m_file[i]->records_in_range(inx, min_key, max_key);
-  }
+      in_range+= (*file)->records_in_range(inx, min_key, max_key);
+  } while (*(++file));
   DBUG_RETURN(in_range);
 }
 
 
 ha_rows ha_partition::estimate_rows_upper_bound()
 {
-  int i= 0;
+  handler **file;
   ha_rows rows, tot_rows= 0;
   DBUG_ENTER("ha_partition::estimate_rows_upper_bound");
 
-  for (i= 0; i < (int) m_part_info->no_parts; i++)
+  do
   {
+    int i= file - m_file;
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
     {
-      rows= m_file[i]->estimate_rows_upper_bound();
+      rows= (*file)->estimate_rows_upper_bound();
 
       if (rows == HA_POS_ERROR)
         DBUG_RETURN(HA_POS_ERROR);
       tot_rows+= rows;
     }
-  }
+  } while (*(++file));
   DBUG_RETURN(tot_rows);
 }
 
Thread
bk commit into 5.1 tree (patg:1.2020)Patrick Galbraith4 Jan