more efficient version of this?
Posted
by
john connor
on Stack Overflow
See other posts from Stack Overflow
or by john connor
Published on 2010-12-29T09:47:34Z
Indexed on
2010/12/29
9:53 UTC
Read the original article
Hit count: 179
algorithm
i have this thingy here :
function numOfPackets(bufferSize, packetSize) {
if (bufferSize <= 0 || packetSize > bufferSize) return 0;
if (packetSize < 0) throw Error();
var out = 0;
for(;;){
out++;
bufferSize = bufferSize - packetSize;
if( packetSize > bufferSize ) break;
}
return out;
}
which i run at often , can u give me more efficent variant of it?
© Stack Overflow or respective owner