From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 20 Apr 92 21:11:35 GMT From: sdd.hp.com!cs.utexas.edu!ut-emx!hasan@hplabs.hpl.hp.com (David A. Hasan) Subject: Re: loop indices Message-ID: <70647@ut-emx.uucp> List-Id: In article <70628@ut-emx.uucp> hasan@ut-emx.uucp (David A. Hasan) writes: > > DECLARE > TYPE Index_1 IS (a,b,c,d,e,f,g); > TYPE Array_1 IS ARRAY(Index_Type1 RANGE <>) OF Integer; > > TYPE Index_2 IS (aa,bb,cc,dd,ee,ff,gg); > TYPE Array_2 IS ARRAY(Index_Type2 RANGE <>) OF Integer; > > v1 : Array_1( a..e ); > v2 : Array_2( bb..ff ); > i1 : Index_1; > i2 : Index_2; > BEGIN > i1 := v1'FIRST; > i2 := v2'FIRST; > FOR i IN 1..5 LOOP > v1(i1) := v2(i2); > IF i<5 THEN > i1 := Index_1'SUCC( i1 ); > i2 := Index_2'SUCC( i2 ); > END IF; > END LOOP; > END; > >My first question is this: does this code carry a performance >hit with it (relative to analogous code which works with >'POS and 'VAL)? > At the expense of making a simple quesiont drag out too long, I've got one data point here which might answer my own question. I see three general approaches to this problem. The are i1 := first_element_in_v1; i2 := first_element_inv2; FOR i IN 1..number_of_elements LOOP v1(i1) := v2(i2); EXIT WHEN i=number_of_elements; i1 := ...'SUCC( i1 ); i2 := ...'SUCC( i2 ); END LOOP; or i1 := ...; i2 := ...; FOR ... LOOP ... IF i