mirror of https://github.com/postgres/postgres
Replace gratuitous memmove() with memcpy()
The index access methods all had similar code that copied the passed-in scan keys to local storage. They all used memmove() for that, which is not wrong, but it seems confusing not to use memcpy() when that would work. Presumably, this was all once copied from ancient code and never adjusted. Discussion: https://www.postgresql.org/message-id/flat/f8c739d9-f48d-4187-b214-df3391ba41ab@eisentraut.org
This commit is contained in:
parent
842265631d
commit
8b5c6a54c4
|
@ -55,10 +55,7 @@ blrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
|||
so->sign = NULL;
|
||||
|
||||
if (scankey && scan->numberOfKeys > 0)
|
||||
{
|
||||
memmove(scan->keyData, scankey,
|
||||
scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
}
|
||||
memcpy(scan->keyData, scankey, scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -956,8 +956,7 @@ brinrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
|||
*/
|
||||
|
||||
if (scankey && scan->numberOfKeys > 0)
|
||||
memmove(scan->keyData, scankey,
|
||||
scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
memcpy(scan->keyData, scankey, scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -447,10 +447,7 @@ ginrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
|||
ginFreeScanKeys(so);
|
||||
|
||||
if (scankey && scan->numberOfKeys > 0)
|
||||
{
|
||||
memmove(scan->keyData, scankey,
|
||||
scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
}
|
||||
memcpy(scan->keyData, scankey, scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -233,8 +233,7 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys,
|
|||
fn_extras[i] = scan->keyData[i].sk_func.fn_extra;
|
||||
}
|
||||
|
||||
memmove(scan->keyData, key,
|
||||
scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
memcpy(scan->keyData, key, scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
|
||||
/*
|
||||
* Modify the scan key so that the Consistent method is called for all
|
||||
|
@ -289,8 +288,7 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys,
|
|||
fn_extras[i] = scan->orderByData[i].sk_func.fn_extra;
|
||||
}
|
||||
|
||||
memmove(scan->orderByData, orderbys,
|
||||
scan->numberOfOrderBys * sizeof(ScanKeyData));
|
||||
memcpy(scan->orderByData, orderbys, scan->numberOfOrderBys * sizeof(ScanKeyData));
|
||||
|
||||
so->orderByTypes = (Oid *) palloc(scan->numberOfOrderBys * sizeof(Oid));
|
||||
|
||||
|
|
|
@ -415,11 +415,7 @@ hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
|||
|
||||
/* Update scan key, if a new one is given */
|
||||
if (scankey && scan->numberOfKeys > 0)
|
||||
{
|
||||
memmove(scan->keyData,
|
||||
scankey,
|
||||
scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
}
|
||||
memcpy(scan->keyData, scankey, scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
|
||||
so->hashso_buc_populated = false;
|
||||
so->hashso_buc_split = false;
|
||||
|
|
|
@ -404,9 +404,7 @@ btrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
|||
* Reset the scan keys
|
||||
*/
|
||||
if (scankey && scan->numberOfKeys > 0)
|
||||
memmove(scan->keyData,
|
||||
scankey,
|
||||
scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
memcpy(scan->keyData, scankey, scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
so->numberOfKeys = 0; /* until _bt_preprocess_keys sets it */
|
||||
so->numArrayKeys = 0; /* ditto */
|
||||
}
|
||||
|
|
|
@ -384,16 +384,14 @@ spgrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
|
|||
|
||||
/* copy scankeys into local storage */
|
||||
if (scankey && scan->numberOfKeys > 0)
|
||||
memmove(scan->keyData, scankey,
|
||||
scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
memcpy(scan->keyData, scankey, scan->numberOfKeys * sizeof(ScanKeyData));
|
||||
|
||||
/* initialize order-by data if needed */
|
||||
if (orderbys && scan->numberOfOrderBys > 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
memmove(scan->orderByData, orderbys,
|
||||
scan->numberOfOrderBys * sizeof(ScanKeyData));
|
||||
memcpy(scan->orderByData, orderbys, scan->numberOfOrderBys * sizeof(ScanKeyData));
|
||||
|
||||
for (i = 0; i < scan->numberOfOrderBys; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue