Re: compare a list of integers

Tech-Archive recommends: Fix windows errors by optimizing your registry



but I thought extension methods would make things slow? been trying to avoid
them

Why would you think that? OK, in reality you could shave a few cycles
if you know you have List<T> by checking the length first
(SequenceEqual doesn't do this, although this could be a missed
opportunity - it could check if both operands implement IList, and
compare the length) - and because it is using the interface (rather
than direct to the sealed List<T>) it won't inline any of the fetches
- but this is rarely the most significant thing.

My advice: use the simplest code that clearly expresses what you want
to do. SequenceEqual does this; *if* you later find this is a
bottleneck, then tweak it (perhaps introduce a List<T> SequenceEqual
extension method) - but until then you're optimising prematurely.

Marc
.



Relevant Pages

  • Re: Proposal for an Improved Scientific Notation
    ... I assert that the fundamental atoms of reality are cycles, ... Have no zero, but would allow any point on a circle ...
    (sci.physics)
  • Re: HA
    ... 5kv7peF5n031U3@xxxxxxxxxxxxxxxxxx, I, Marvo, say: ... in reality it is no more logical or ... How many electrons per second in an amp? ... cycles per second. ...
    (uk.rec.waterways)
  • Re: 6502 bit hacks
    ... Another source of fun/insanity is the use of self-modifying code to ... shave off a few cycles, ...
    (comp.sys.apple2.programmer)