diff --git a/include/ut0sort.h b/include/ut0sort.h
index f75b45f6e89eafacdf9bbf133ab316b5453c9336..02d3772035e0de9bb872f0d7ae0509434e2d96b8 100644
--- a/include/ut0sort.h
+++ b/include/ut0sort.h
@@ -80,9 +80,8 @@ two elements from the array and returns 1, if the first is bigger,
 		}\
 	}\
 \
-	for (ut_sort_i77 = (LOW); ut_sort_i77 < (HIGH); ut_sort_i77++) {\
-		(ARR)[ut_sort_i77] = (AUX_ARR)[ut_sort_i77];\
-	}\
+	memcpy((ARR) + (LOW), (AUX_ARR) + (LOW),\
+	       ((HIGH) - (LOW)) * sizeof *(ARR));\
 }\
 
 
diff --git a/rem/rem0cmp.c b/rem/rem0cmp.c
index f8353000d05cc7f40dd6116b5067ac4a4579952a..f1f656a276f20cedc609956ca44408515526aa8d 100644
--- a/rem/rem0cmp.c
+++ b/rem/rem0cmp.c
@@ -459,10 +459,10 @@ cmp_dtuple_rec_with_match(
 						     rec_offs_comp(offsets));
 		ulint	tup_info = dtuple_get_info_bits(dtuple);
 
-		if (rec_info & REC_INFO_MIN_REC_FLAG) {
+		if (UNIV_UNLIKELY(rec_info & REC_INFO_MIN_REC_FLAG)) {
 			ret = !(tup_info & REC_INFO_MIN_REC_FLAG);
 			goto order_resolved;
-		} else if (tup_info & REC_INFO_MIN_REC_FLAG) {
+		} else if (UNIV_UNLIKELY(tup_info & REC_INFO_MIN_REC_FLAG)) {
 			ret = -1;
 			goto order_resolved;
 		}
@@ -598,7 +598,7 @@ cmp_dtuple_rec_with_match(
 			}
 
 			ret = (int) (dtuple_byte - rec_byte);
-			if (UNIV_UNLIKELY(ret)) {
+			if (UNIV_LIKELY(ret)) {
 				if (ret < 0) {
 					ret = -1;
 					goto order_resolved;
@@ -940,8 +940,8 @@ cmp_rec_rec_with_match(
 			if (cur_field == 0) {
 				/* Test if rec is the predefined minimum
 				record */
-				if (rec_get_info_bits(rec1, comp)
-				    & REC_INFO_MIN_REC_FLAG) {
+				if (UNIV_UNLIKELY(rec_get_info_bits(rec1, comp)
+						  & REC_INFO_MIN_REC_FLAG)) {
 
 					if (!(rec_get_info_bits(rec2, comp)
 					      & REC_INFO_MIN_REC_FLAG)) {
@@ -950,8 +950,9 @@ cmp_rec_rec_with_match(
 
 					goto order_resolved;
 
-				} else if (rec_get_info_bits(rec2, comp)
-					   & REC_INFO_MIN_REC_FLAG) {
+				} else if (UNIV_UNLIKELY
+					   (rec_get_info_bits(rec2, comp)
+					    & REC_INFO_MIN_REC_FLAG)) {
 
 					ret = 1;
 
@@ -1148,8 +1149,9 @@ cmp_debug_dtuple_rec_with_match(
 	cur_field = *matched_fields;
 
 	if (cur_field == 0) {
-		if (rec_get_info_bits(rec, rec_offs_comp(offsets))
-		    & REC_INFO_MIN_REC_FLAG) {
+		if (UNIV_UNLIKELY
+		    (rec_get_info_bits(rec, rec_offs_comp(offsets))
+		     & REC_INFO_MIN_REC_FLAG)) {
 
 			ret = !(dtuple_get_info_bits(dtuple)
 				& REC_INFO_MIN_REC_FLAG);
@@ -1157,7 +1159,8 @@ cmp_debug_dtuple_rec_with_match(
 			goto order_resolved;
 		}
 
-		if (dtuple_get_info_bits(dtuple) & REC_INFO_MIN_REC_FLAG) {
+		if (UNIV_UNLIKELY
+		    (dtuple_get_info_bits(dtuple) & REC_INFO_MIN_REC_FLAG)) {
 			ret = -1;
 
 			goto order_resolved;