Richard Heathfield
1/18/2016 3:25:00 PM
On 18/01/16 15:18, mack.altmaniii@gmail.com wrote:
> I started web designing when I was a teen, which at that time web sites were what is now referred to as 'static' in nature. However, I grew with the community and began transitioning from designer to developer to create more 'dynamic' web sites using various various languages I picked up along the way. Although I had my own web design company as a teenager in high school, I pursued a career in accounting while considering my 'tech' skills a hobby. Unfortunately, I was ill-advised by many saying it would never amount to anything. Fastforward a decade, I sit in a position where I use Caché (Mumps) on a daily basis. However, I often question my 'self taught' skills. While I would say I learned them often by tested (time and again) trial and error, I still doubt them.
>
> While I believe this can be answered by any mathematics lover (Who didn't love proofs? Ha!), I want to ask so I stop questioning myself and educate those I'm having to come behind. I feel its a waste of performance, and want to feel confident in saying it is. So here goes.
>
>
> The following is what I am referring to.
>
> if (id = 1) {
> set $piece(^|"app"|global("index"),"^",1)=$horolog
> }
> if (id = 2) {
> set $piece(^|"app"|global("index"),"^",3)=$horolog
> }
> if (id = 3) {
> set $piece(^|"app"|global("index"),"^",5)=$horolog
> }
> if (id = 4) {
> set $piece(^|"app"|global("index"),"^",7)=$horolog
> }
> if (id = 5) {
> set $piece(^|"app"|global("index"),"^",9)=$horolog
> }
>
> I feel each pass through the above wastes performance fivefold.
> The variable (id) is only going to be equal to one of the five
> each time it reaches this point, as it is not changed within
> the if() so why would we verify it hasn't changed when there's
> nothing telling it to change. I feel the above should be written
> as follows. Would anyone write the above in the same way or would
> everyone use the following approach?
>
> if (id = 1) {
> set $piece(^|"app"|global("index"),"^",1)=$horolog
> } elseif (id = 2) {
> set $piece(^|"app"|global("index"),"^",3)=$horolog
> } elseif (id = 3) {
> set $piece(^|"app"|global("index"),"^",5)=$horolog
> } elseif (id = 4) {
> set $piece(^|"app"|global("index"),"^",7)=$horolog
> } elseif (id = 5) {
> set $piece(^|"app"|global("index"),"^",9)=$horolog
> }
set $piece(^|"app"|global("index"),"^",id * 2 - 1) = $horolog
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within