You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At full speed parsing, this can happen in a matter of milliseconds.
varMessage=require('..');functionunbuffer(){varstart=process.hrtime();for(vari=0;;i++){varmsg=newMessage;varbuf=newBuffer(4);buf[0]=(Math.random()*256)|0;buf[1]=(Math.random()*256)|0;buf[2]=123;buf[3]=125;msg.push(buf);varargs=newMessage(msg.toBuffer()).args;if(!Buffer.isBuffer(args[0])){console.log('not a buffer',args[0]);return[start,process.hrtime()];}}}functionms(times){return(times[1][0]*1000+times[1][1]/1000000)-(times[0][0]*1000+times[0][1]/1000000);}console.log(ms(unbuffer())+' ms');
not a buffer {}
228.04162900149822 ms
not a buffer {}
62.09908200055361 ms
not a buffer {}
100.19535400345922 ms
not a buffer {}
18.36940200254321 ms
not a buffer {}
68.66924300044775 ms
not a buffer {}
11.645527001470327 ms
not a buffer {}
190.55536199733615 ms
not a buffer {}
125.49566200003028 ms
not a buffer {}
111.19815300032496 ms
not a buffer {}
9.694663997739553 ms
The text was updated successfully, but these errors were encountered:
Buffers aren't prefixed, leading to behavior like this:
Which causes problems if you want to support arbitrary buffer data.
At full speed parsing, this can happen in a matter of milliseconds.
The text was updated successfully, but these errors were encountered: