Skip to content

Commit 89e01ea

Browse files
committed
Use a Float32Array as the temporary buffer to avoid implicit casts
1 parent fec11b2 commit 89e01ea

File tree

1 file changed

+6
-6
lines changed
  • lib/node_modules/@stdlib/array/complex64/lib

1 file changed

+6
-6
lines changed

lib/node_modules/@stdlib/array/complex64/lib/main.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -810,14 +810,14 @@ Object.defineProperty( Complex64Array.prototype, 'length', {
810810
*
811811
* ## Notes
812812
*
813-
* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are only concerned with the following scenario:
813+
* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:
814814
*
815815
* ```text
816816
* buf: ---------------------
817817
* src: ---------------------
818818
* ```
819819
*
820-
* In the above, as we copy over values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.
820+
* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.
821821
*
822822
* In the other overlapping scenario,
823823
*
@@ -922,9 +922,9 @@ Object.defineProperty( Complex64Array.prototype, 'set', {
922922
)
923923
) {
924924
// We need to copy source values...
925-
tmp = [];
925+
tmp = new Float32Array( N );
926926
for ( i = 0; i < N; i++ ) {
927-
tmp.push( sbuf[ i ] );
927+
tmp[ i ] = sbuf[ i ];
928928
}
929929
sbuf = tmp;
930930
}
@@ -967,9 +967,9 @@ Object.defineProperty( Complex64Array.prototype, 'set', {
967967
)
968968
) {
969969
// We need to copy source values...
970-
tmp = [];
970+
tmp = new Float32Array( N );
971971
for ( i = 0; i < N; i++ ) {
972-
tmp.push( sbuf[ i ] );
972+
tmp[ i ] = sbuf[ i ];
973973
}
974974
sbuf = tmp;
975975
}

0 commit comments

Comments
 (0)