Re: performance question
From: Amey Samant (ameyas7_at_yahoo.com)
Date: 10/25/03
- Next message: Amey Samant: "Re: newbie with compiling"
- Previous message: Chris: "Re: handling focusLost Events"
- In reply to: Murat Tasan: "performance question"
- Next in thread: Phil...: "Re: performance question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Oct 2003 02:37:41 -0700
Murat Tasan <tasan@eecs.cwru.edu> wrote in message news:<Pine.SOL.4.53.0310231524410.28593@homer>...
> let's say i have a program that uses an array.
> and many times in the program i need to do computation that rely on the
> array's length.
>
> so, how much speedup (if any at all) is there to storing the array length
> as an int and using that in the computations, compared with constantly
> using the arrayName.length method?
> murat
hi
in your example, your method has following disadvantages
1) you must update length variable as and when array is allocated new
elements
for eg
if in your prog you have something like arr=new int[5]; then you must
update length variable maintained by you.
2) its a duplicate variable ... i mean arr.length is a variable & not
a method, so why you want to maintain a copy of original variable
3) if you have 10 arrays , do you want to allocate 10 variables for
maintaining array size when its already taken care of ....
or would you go for havin an array of size 10 say lengths[10] ;) &
then maintain size of this array in seperate variable ;)
hope i made it clear
regards
amey
- Next message: Amey Samant: "Re: newbie with compiling"
- Previous message: Chris: "Re: handling focusLost Events"
- In reply to: Murat Tasan: "performance question"
- Next in thread: Phil...: "Re: performance question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|