Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf50b103

Browse files
committed
From: "D'Arcy J.M. Cain" <darcy@druid.net>
Subject: [HACKERS] backend/optimizer/geqo/geqo_erx.cI sent these changes in with a bunch of others. Some were folded in butothers, like these, were not. I am not sure why so I am resending thisto the developers list by itself for discussion.The readon why I suggest these changes is that the compiler can't tellthat minimum_count is initialized before it is used. The tests that Iadd in here will cause an immediate error if it doesn't. As the commentsbelow suggest, if it is 100% guaranteed that the variable will alwaysbe initialized then how this is so should be commented here. I don'tknow how much strain the actual test puts on the performance but if itisn't too much then maybe leave it in for absolute safety anyway.There are also a few returns just to stop warnings.
1 parenta668b7a commitf50b103

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

‎src/backend/optimizer/geqo/geqo_erx.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* geqo_erx.c--
44
* edge recombination crossover [ER]
55
*
6-
* $Id: geqo_erx.c,v 1.1 1997/02/19 12:56:55 scrappy Exp $
6+
* $Id: geqo_erx.c,v 1.2 1997/06/06 00:37:23 scrappy Exp $
77
*
88
*-------------------------------------------------------------------------
99
*/
@@ -278,7 +278,7 @@ gimme_gene (Edge edge, Edge *edge_table)
278278
inti;
279279
Genefriend;
280280
intminimum_edges;
281-
intminimum_count;
281+
intminimum_count=-1;
282282
intrand_decision;
283283

284284
/* no point has edges to more than 4 other points
@@ -299,18 +299,27 @@ gimme_gene (Edge edge, Edge *edge_table)
299299
if (friend<0)return ( (Gene)Abs(friend));
300300

301301

302-
/* give priority to candidates with fewest remaining unused edges;
303-
find out what the minimum number of unused edges is (minimum_edges);
304-
if there is more than one cadidate with the minimum number
305-
of unused edges keep count of this number (minimum_count); */
306-
302+
/* give priority to candidates with fewest remaining unused edges;
303+
find out what the minimum number of unused edges is (minimum_edges);
304+
if there is more than one cadidate with the minimum number
305+
of unused edges keep count of this number (minimum_count); */
306+
307+
/* The test for minimum_count can probably be removed at some
308+
point but comments should probably indicate exactly why it
309+
is guaranteed that the test will always succeed the first
310+
time around. If it can fail then the code is in error */
311+
312+
307313
if (edge_table[(int)friend].unused_edges<minimum_edges) {
308314
minimum_edges=edge_table[(int)friend].unused_edges;
309315
minimum_count=1;
310316
}
311-
else
312-
if (edge_table[(int)friend].unused_edges==minimum_edges)
313-
minimum_count++;
317+
else
318+
if (minimum_count==-1)
319+
elog(WARN,"gimme_gene: Internal error - minimum_count not set");
320+
else
321+
if (edge_table[(int)friend].unused_edges==minimum_edges)
322+
minimum_count++;
314323

315324
}/* for (i=0; i<edge.unused_edges; i++) */
316325

@@ -332,6 +341,7 @@ gimme_gene (Edge edge, Edge *edge_table)
332341

333342
/* ... should never be reached */
334343
elog(WARN,"gimme_gene: neither shared nor minimum number nor random edge found");
344+
return0;/* to keep the compiler quiet */
335345
}
336346

337347
/* edge_failure--
@@ -420,5 +430,6 @@ edge_failure (Gene *gene, int index, Edge *edge_table, int num_gene)
420430

421431
/* ... should never be reached */
422432
elog(WARN,"edge_failure: no edge detected");
433+
return0;/* to keep the compiler quiet */
423434
}
424435

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp