1
1
/// <reference path="./rt/index.d.ts" />
2
2
3
3
import { BLOCK_MAXSIZE } from "./rt/common" ;
4
+ import { Runtime } from "shared/runtime" ;
4
5
import { COMPARATOR , SORT } from "./util/sort" ;
5
6
import { REVERSE } from "./util/bytes" ;
6
7
import { joinBooleanArray , joinIntegerArray , joinFloatArray , joinStringArray , joinReferenceArray } from "./util/string" ;
@@ -22,7 +23,11 @@ function ensureCapacity(array: usize, newSize: usize, alignLog2: u32, canGrow: b
22
23
let newCapacity = max ( newSize , MIN_SIZE ) << alignLog2 ;
23
24
if ( canGrow ) newCapacity = max ( min ( oldCapacity << 1 , BLOCK_MAXSIZE ) , newCapacity ) ;
24
25
let newData = __renew ( oldData , newCapacity ) ;
25
- memory . fill ( newData + oldCapacity , 0 , newCapacity - oldCapacity ) ;
26
+ // __new / __renew already init memory range as zeros in Incremental runtime.
27
+ // So try to avoid this.
28
+ if ( ASC_RUNTIME != Runtime . Incremental ) {
29
+ memory . fill ( newData + oldCapacity , 0 , newCapacity - oldCapacity ) ;
30
+ }
26
31
if ( newData !== oldData ) { // oldData has been free'd
27
32
store < usize > ( array , newData , offsetof < ArrayBufferView > ( "buffer" ) ) ;
28
33
store < usize > ( array , newData , offsetof < ArrayBufferView > ( "dataStart" ) ) ;
@@ -66,7 +71,9 @@ export class Array<T> {
66
71
// reserve capacity for at least MIN_SIZE elements
67
72
var bufferSize = max ( < usize > length , MIN_SIZE ) << alignof < T > ( ) ;
68
73
var buffer = changetype < ArrayBuffer > ( __new ( bufferSize , idof < ArrayBuffer > ( ) ) ) ;
69
- memory . fill ( changetype < usize > ( buffer ) , 0 , bufferSize ) ;
74
+ if ( ASC_RUNTIME != Runtime . Incremental ) {
75
+ memory . fill ( changetype < usize > ( buffer ) , 0 , bufferSize ) ;
76
+ }
70
77
this . buffer = buffer ; // links
71
78
this . dataStart = changetype < usize > ( buffer ) ;
72
79
this . byteLength = < i32 > bufferSize ;
0 commit comments