1. Unoptimized slicing?

a = rand(repeat(200, 200))

I found that the operation

  c = a[1..length(a)]
     or
  c = a[1..200]

is much slower than

  c = a

Why isn't it optimized? (check the length of the slice, if it's equal
to the original sequence the pointer should be copied not the
contents)

new topic     » topic index » view message » categorize

2. Re: Unoptimized slicing?

aku saya wrote:
> a = rand(repeat(200, 200))
> 
> I found that the operation
> 
>   c = a[1..length(a)]
>      or
>   c = a[1..200]
> 
> is much slower than
> 
>   c = a
> 
> Why isn't it optimized? (check the length of the slice, if it's equal
> to the original sequence the pointer should be copied not the
> contents)

Thanks. I'll think about it.
With a special case optimization like this,
you waste a bit of time checking for the condition
hundreds, or maybe thousands, of times for each
time it actually occurs.

Regards,
    Rob Craig
    Rapid Deployment Software
    http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu