Commit 2eb32d30 authored by marko's avatar marko

branches/zip: Minor cleanup.

log_block_calc_checksum(), log_block_get_checksum(): Add const qualifiers.

log_block_calc_checksum(): Split a long expression to more readable chunks.
Some compilers might optimize this better.
parent 43becedf
...@@ -417,16 +417,16 @@ UNIV_INLINE ...@@ -417,16 +417,16 @@ UNIV_INLINE
ulint ulint
log_block_calc_checksum( log_block_calc_checksum(
/*====================*/ /*====================*/
/* out: checksum */ /* out: checksum */
byte* block); /* in: log block */ const byte* block); /* in: log block */
/**************************************************************** /****************************************************************
Gets a log block checksum field value. */ Gets a log block checksum field value. */
UNIV_INLINE UNIV_INLINE
ulint ulint
log_block_get_checksum( log_block_get_checksum(
/*===================*/ /*===================*/
/* out: checksum */ /* out: checksum */
byte* log_block); /* in: log block */ const byte* log_block); /* in: log block */
/**************************************************************** /****************************************************************
Sets a log block checksum field value. */ Sets a log block checksum field value. */
UNIV_INLINE UNIV_INLINE
......
...@@ -188,8 +188,8 @@ UNIV_INLINE ...@@ -188,8 +188,8 @@ UNIV_INLINE
ulint ulint
log_block_calc_checksum( log_block_calc_checksum(
/*====================*/ /*====================*/
/* out: checksum */ /* out: checksum */
byte* block) /* in: log block */ const byte* block) /* in: log block */
{ {
ulint sum; ulint sum;
ulint sh; ulint sh;
...@@ -199,8 +199,10 @@ log_block_calc_checksum( ...@@ -199,8 +199,10 @@ log_block_calc_checksum(
sh = 0; sh = 0;
for (i = 0; i < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE; i++) { for (i = 0; i < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE; i++) {
sum = sum & 0x7FFFFFFFUL; ulint b = (ulint) block[i];
sum += (((ulint)(*(block + i))) << sh) + (ulint)(*(block + i)); sum &= 0x7FFFFFFFUL;
sum += b;
sum += b << sh;
sh++; sh++;
if (sh > 24) { if (sh > 24) {
sh = 0; sh = 0;
...@@ -216,8 +218,8 @@ UNIV_INLINE ...@@ -216,8 +218,8 @@ UNIV_INLINE
ulint ulint
log_block_get_checksum( log_block_get_checksum(
/*===================*/ /*===================*/
/* out: checksum */ /* out: checksum */
byte* log_block) /* in: log block */ const byte* log_block) /* in: log block */
{ {
return(mach_read_from_4(log_block + OS_FILE_LOG_BLOCK_SIZE return(mach_read_from_4(log_block + OS_FILE_LOG_BLOCK_SIZE
- LOG_BLOCK_CHECKSUM)); - LOG_BLOCK_CHECKSUM));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment