summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <marko@hundin.mysql.fi>2005-06-22 12:36:24 +0300
committerunknown <marko@hundin.mysql.fi>2005-06-22 12:36:24 +0300
commit25436b693d1b9d414e131ba121020e74c1f4afd6 (patch)
tree905c3919d739c5a93185d374ae6d7f2fca3052d9
parente4346cae0a64c896f0560ec2ccb6b37ef3bb9ef4 (diff)
downloadmariadb-git-25436b693d1b9d414e131ba121020e74c1f4afd6.tar.gz
InnoDB: Replace for loops with memset() where possible.
innobase/btr/btr0cur.c: Replace for loop with memset() innobase/buf/buf0buf.c: buf_print(): Remove for loop for initializing counts[]. Similar to index_ids[], the elements of this array will be initialized when they are allocated, i.e., counts[n_found++] = 1. innobase/os/os0file.c: Replace for loop with memset() innobase/page/page0page.c: Replace for loop with memset() innobase/trx/trx0rec.c: Replace for loop with memset()
-rw-r--r--innobase/btr/btr0cur.c4
-rw-r--r--innobase/buf/buf0buf.c4
-rw-r--r--innobase/os/os0file.c5
-rw-r--r--innobase/page/page0page.c4
-rw-r--r--innobase/trx/trx0rec.c8
5 files changed, 6 insertions, 19 deletions
diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c
index 98d90ecf18a..4ae27f007d6 100644
--- a/innobase/btr/btr0cur.c
+++ b/innobase/btr/btr0cur.c
@@ -2847,9 +2847,7 @@ btr_estimate_number_of_different_key_vals(
n_diff = mem_alloc((n_cols + 1) * sizeof(ib_longlong));
- for (j = 0; j <= n_cols; j++) {
- n_diff[j] = 0;
- }
+ memset(n_diff, 0, (n_cols + 1) * sizeof(ib_longlong));
/* We sample some pages in the index to get an estimate */
diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c
index 78189617aab..fe4498e6f10 100644
--- a/innobase/buf/buf0buf.c
+++ b/innobase/buf/buf0buf.c
@@ -2101,10 +2101,6 @@ buf_print(void)
n_found = 0;
- for (i = 0 ; i < size; i++) {
- counts[i] = 0;
- }
-
for (i = 0; i < size; i++) {
frame = buf_pool_get_nth_block(buf_pool, i)->frame;
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c
index 8102f24f25a..c68f5738798 100644
--- a/innobase/os/os0file.c
+++ b/innobase/os/os0file.c
@@ -1672,7 +1672,6 @@ os_file_set_size(
ibool ret;
byte* buf;
byte* buf2;
- ulint i;
ut_a(size == (size & 0xFFFFFFFF));
@@ -1685,9 +1684,7 @@ os_file_set_size(
buf = ut_align(buf2, UNIV_PAGE_SIZE);
/* Write buffer full of zeros */
- for (i = 0; i < UNIV_PAGE_SIZE * 512; i++) {
- buf[i] = '\0';
- }
+ memset(buf, 0, UNIV_PAGE_SIZE * 512);
offset = 0;
low = (ib_longlong)size + (((ib_longlong)size_high) << 32);
diff --git a/innobase/page/page0page.c b/innobase/page/page0page.c
index 9c957ac8554..1fe7f1d9356 100644
--- a/innobase/page/page0page.c
+++ b/innobase/page/page0page.c
@@ -1755,9 +1755,7 @@ page_validate(
records in the page record heap do not overlap */
buf = mem_heap_alloc(heap, UNIV_PAGE_SIZE);
- for (i = 0; i < UNIV_PAGE_SIZE; i++) {
- buf[i] = 0;
- }
+ memset(buf, 0, UNIV_PAGE_SIZE);
/* Check first that the record heap and the directory do not
overlap. */
diff --git a/innobase/trx/trx0rec.c b/innobase/trx/trx0rec.c
index 3f3cfd3b000..3b7171e6038 100644
--- a/innobase/trx/trx0rec.c
+++ b/innobase/trx/trx0rec.c
@@ -941,13 +941,11 @@ trx_undo_erase_page_end(
mtr_t* mtr) /* in: mtr */
{
ulint first_free;
- ulint i;
-
+
first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_FREE);
- for (i = first_free; i < UNIV_PAGE_SIZE - FIL_PAGE_DATA_END; i++) {
- undo_page[i] = 0xFF;
- }
+ memset(undo_page + first_free, 0xff,
+ (UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) - first_free);
mlog_write_initial_log_record(undo_page, MLOG_UNDO_ERASE_END, mtr);
}