Skip to content

Commit

Permalink
Orangefs: optimize boilerplate code.
Browse files Browse the repository at this point in the history
Suggested by David Binderman <dcb314@hotmail.com>
The former can potentially be a performance win over the latter.

memcpy(d, s, len);
memset(d+len, c, size-len);

memset(d, c, size);
memcpy(d, s, len);

Signed-off-by: Mike Marshall <hubcap@omnibond.com>
  • Loading branch information
hubcapsc committed Apr 8, 2016
1 parent 2d09a2c commit a9bb3ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/orangefs/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ static inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh,
void *p, int size)
{

memset(p, 0, size);
memcpy(p, kh->u, 16);
memset(p + 16, 0, size - 16);

}

Expand Down
2 changes: 1 addition & 1 deletion fs/orangefs/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *prefix,
goto out_release_op;
}

memset(buffer, 0, size);
memcpy(buffer, new_op->downcall.resp.getxattr.val, length);
memset(buffer + length, 0, size - length);
gossip_debug(GOSSIP_XATTR_DEBUG,
"orangefs_inode_getxattr: inode %pU "
"key %s key_sz %d, val_len %d\n",
Expand Down

0 comments on commit a9bb3ba

Please sign in to comment.