mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-21 12:41:26 +00:00
Micro-optimize scst_adjust_sg() and scst_restore_sg_buff()
Micro-optimize scst_adjust_sg() and scst_restore_sg_buff() by replacing two variables (orig_sg and orig_sg_entry, a pointer and an integer) by one variable (orig_sg_entry, a pointer to a scatterlist element). This allows to eliminate one assignment in scst_adjust_sg() and one read in scst_restore_sg_buff(). Signed-off-by: Bart Van Assche <bvanassche@acm.org> git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4666 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -2137,9 +2137,10 @@ struct scst_cmd {
|
||||
void *dh_priv;
|
||||
|
||||
/* Used to restore sg if it was modified by scst_adjust_sg() */
|
||||
struct scatterlist *orig_sg;
|
||||
int *p_orig_sg_cnt;
|
||||
int orig_sg_cnt, orig_sg_entry, orig_entry_len;
|
||||
int orig_sg_cnt;
|
||||
struct scatterlist *orig_sg_entry;
|
||||
int orig_entry_len;
|
||||
|
||||
/* Used to retry commands in case of double UA */
|
||||
int dbl_ua_orig_resp_data_len, dbl_ua_orig_data_direction;
|
||||
|
||||
@@ -2813,10 +2813,9 @@ static void scst_adjust_sg(struct scst_cmd *cmd, struct scatterlist *sg,
|
||||
sg, *sg_cnt, adjust_len, i, j,
|
||||
sg[j].length, left);
|
||||
#endif
|
||||
cmd->orig_sg = sg;
|
||||
cmd->p_orig_sg_cnt = sg_cnt;
|
||||
cmd->orig_sg_cnt = *sg_cnt;
|
||||
cmd->orig_sg_entry = j;
|
||||
cmd->orig_sg_entry = &sg[j];
|
||||
cmd->orig_entry_len = sg[j].length;
|
||||
*sg_cnt = (left > 0) ? j+1 : j;
|
||||
sg[j].length = left;
|
||||
@@ -2836,11 +2835,11 @@ static void scst_adjust_sg(struct scst_cmd *cmd, struct scatterlist *sg,
|
||||
*/
|
||||
void scst_restore_sg_buff(struct scst_cmd *cmd)
|
||||
{
|
||||
TRACE_MEM("cmd %p, sg %p, orig_sg_entry %d, "
|
||||
"orig_entry_len %d, orig_sg_cnt %d", cmd, cmd->orig_sg,
|
||||
TRACE_MEM("cmd %p, sg %p, orig_sg_entry %p, "
|
||||
"orig_entry_len %d, orig_sg_cnt %d", cmd, cmd->sg,
|
||||
cmd->orig_sg_entry, cmd->orig_entry_len,
|
||||
cmd->orig_sg_cnt);
|
||||
cmd->orig_sg[cmd->orig_sg_entry].length = cmd->orig_entry_len;
|
||||
cmd->orig_sg_entry->length = cmd->orig_entry_len;
|
||||
*cmd->p_orig_sg_cnt = cmd->orig_sg_cnt;
|
||||
cmd->sg_buff_modified = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user