Results 1 to 2 of 2

Thread: [RESOLVED] array_shift() vs. array_reverse() + array_pop()

  1. #1

    Thread Starter
    Hyperactive Member tomcatexodus's Avatar
    Join Date
    Feb 2001
    Posts
    372

    Resolved [RESOLVED] array_shift() vs. array_reverse() + array_pop()

    I've read the benchmarking tests conducted on large iterations of data removal from an array using either array_shift() or array_reverse() + array_pop(). array_shift() fails hugely, obviously for having to re-index the entire array.

    My question is though; on smaller tests, involving an array with no more than 5 - 10 elements it shouldn't make a significant difference. But how much processing overhead is associated with using array_shift()? What I mean is, if a page using array_shift() on a 5 - 10 element array, is called several times a second, will that still cause significant lag?
    IWS

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: array_shift() vs. array_reverse() + array_pop()

    you will probably not notice the difference. my thinking is that you shouldn't over optimize anything -- write code in the clearest way possible, and if this becomes the bottleneck, optimize it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width