Commit 369da8f5 authored by unknown's avatar unknown
Browse files

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()
parent 283d42e5
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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 */
	
+0 −4
Original line number Diff line number Diff line
@@ -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;

+1 −4
Original line number Diff line number Diff line
@@ -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);
+1 −3
Original line number Diff line number Diff line
@@ -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. */
+3 −5
Original line number Diff line number Diff line
@@ -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);
}