@@ -9,7 +9,7 @@ import binary.types;
9
9
import std.algorithm : each;
10
10
import std.bitmanip : read;
11
11
import std.exception : enforce;
12
- import std.range : iota ;
12
+ import std.range : popFrontExactly ;
13
13
import std.system : Endian;
14
14
import std.typecons : Tuple , tuple;
15
15
@@ -148,8 +148,8 @@ Data[] decodeDataSection(ref const(ubyte)[] input)
148
148
auto memoryIndex = input.leb128! uint ();
149
149
auto offset = input.decodeExpr();
150
150
auto size = input.leb128! uint ();
151
- ubyte [] bytes ;
152
- iota(size).each ! (_ => bytes ~= input.read ! ubyte () );
151
+ auto bytes = cast ( ubyte []) input[ 0 .. size] ;
152
+ input.popFrontExactly(size );
153
153
data ~= Data(
154
154
memoryIndex: memoryIndex,
155
155
offset: offset,
@@ -174,11 +174,11 @@ FuncType[] decodeTypeSection(ref const(ubyte)[] input)
174
174
{
175
175
input.read! ubyte ();
176
176
uint size = input.leb128! uint ();
177
- ValueType[] params ;
178
- iota(size).each ! (_ => params ~= input.decodeValueSection() );
177
+ auto params = cast ( ValueType[]) input[ 0 .. size] ;
178
+ input.popFrontExactly(size );
179
179
size = input.leb128! uint ();
180
- ValueType[] results ;
181
- iota(size).each ! (_ => results ~= input.decodeValueSection() );
180
+ auto results = cast ( ValueType[]) input[ 0 .. size] ;
181
+ input.popFrontExactly(size );
182
182
funcTypes ~= FuncType(params, results);
183
183
}
184
184
return funcTypes;
@@ -334,10 +334,9 @@ Import[] decodeImportSection(ref const(ubyte)[] input)
334
334
335
335
string decodeName (ref const (ubyte )[] input)
336
336
{
337
- import std.range : popFrontN;
338
337
const nameLen = input.leb128! uint ();
339
338
auto name = cast (string ) input[0 .. nameLen];
340
- input.popFrontN (nameLen);
339
+ input.popFrontExactly (nameLen);
341
340
return name;
342
341
}
343
342
0 commit comments