HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Funny little code optimisation

Funny little code optimisation I'm in the middle of reviewing a developers code. This amused me…

Code

      var url='';
      if(document.getElementById('file'+number))
      {
         url=document.getElementById('file'+number).value;
      }
      else
      {
         if (filename!='')
         {
            url=filename;
         }
      }

because it is exactly equivalent in behaviour to…

Code

      var url=filename;
      if(document.getElementById('file'+number))
      {
         url=document.getElementById('file'+number).value;
      }

I saw this straight away, and then I thought "hey, that's actually quite a complex optimisation". Are any programmers reading? I'd be interested if this is the kind of thing other people notice, or am I just fussier about things?

View all

Trackbacks

There have been no trackbacks yet

Edited