Fossil SCM
Simplification to the PQueue object to remove the content pointer, which is never used.
Commit
83c4ab60517e4bca2171dd62c15a6d93d1de7d6c4c5e80f8a1f15f33765d2b2a
Parent
274079a2e19a148…
2 files changed
+2
-6
+3
-3
+2
-6
| --- src/pqueue.c | ||
| +++ src/pqueue.c | ||
| @@ -42,11 +42,10 @@ | ||
| 42 | 42 | struct PQueue { |
| 43 | 43 | int cnt; /* Number of entries in the queue */ |
| 44 | 44 | int sz; /* Number of slots in a[] */ |
| 45 | 45 | struct QueueElement { |
| 46 | 46 | int id; /* ID of the element */ |
| 47 | - void *p; /* Content pointer */ | |
| 48 | 47 | double value; /* Value of element. Kept in ascending order */ |
| 49 | 48 | } *a; |
| 50 | 49 | }; |
| 51 | 50 | #endif |
| 52 | 51 | |
| @@ -74,11 +73,11 @@ | ||
| 74 | 73 | } |
| 75 | 74 | |
| 76 | 75 | /* |
| 77 | 76 | ** Insert element e into the queue. |
| 78 | 77 | */ |
| 79 | -void pqueuex_insert(PQueue *p, int e, double v, void *pData){ | |
| 78 | +void pqueuex_insert(PQueue *p, int e, double v){ | |
| 80 | 79 | int i, j; |
| 81 | 80 | if( p->cnt+1>p->sz ){ |
| 82 | 81 | pqueuex_resize(p, p->cnt+5); |
| 83 | 82 | } |
| 84 | 83 | for(i=0; i<p->cnt; i++){ |
| @@ -88,29 +87,26 @@ | ||
| 88 | 87 | } |
| 89 | 88 | break; |
| 90 | 89 | } |
| 91 | 90 | } |
| 92 | 91 | p->a[i].id = e; |
| 93 | - p->a[i].p = pData; | |
| 94 | 92 | p->a[i].value = v; |
| 95 | 93 | p->cnt++; |
| 96 | 94 | } |
| 97 | 95 | |
| 98 | 96 | /* |
| 99 | 97 | ** Extract the first element from the queue (the element with |
| 100 | 98 | ** the smallest value) and return its ID. Return 0 if the queue |
| 101 | 99 | ** is empty. |
| 102 | 100 | */ |
| 103 | -int pqueuex_extract(PQueue *p, void **pp){ | |
| 101 | +int pqueuex_extract(PQueue *p){ | |
| 104 | 102 | int e, i; |
| 105 | 103 | if( p->cnt==0 ){ |
| 106 | - if( pp ) *pp = 0; | |
| 107 | 104 | return 0; |
| 108 | 105 | } |
| 109 | 106 | e = p->a[0].id; |
| 110 | - if( pp ) *pp = p->a[0].p; | |
| 111 | 107 | for(i=0; i<p->cnt-1; i++){ |
| 112 | 108 | p->a[i] = p->a[i+1]; |
| 113 | 109 | } |
| 114 | 110 | p->cnt--; |
| 115 | 111 | return e; |
| 116 | 112 | } |
| 117 | 113 |
| --- src/pqueue.c | |
| +++ src/pqueue.c | |
| @@ -42,11 +42,10 @@ | |
| 42 | struct PQueue { |
| 43 | int cnt; /* Number of entries in the queue */ |
| 44 | int sz; /* Number of slots in a[] */ |
| 45 | struct QueueElement { |
| 46 | int id; /* ID of the element */ |
| 47 | void *p; /* Content pointer */ |
| 48 | double value; /* Value of element. Kept in ascending order */ |
| 49 | } *a; |
| 50 | }; |
| 51 | #endif |
| 52 | |
| @@ -74,11 +73,11 @@ | |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | ** Insert element e into the queue. |
| 78 | */ |
| 79 | void pqueuex_insert(PQueue *p, int e, double v, void *pData){ |
| 80 | int i, j; |
| 81 | if( p->cnt+1>p->sz ){ |
| 82 | pqueuex_resize(p, p->cnt+5); |
| 83 | } |
| 84 | for(i=0; i<p->cnt; i++){ |
| @@ -88,29 +87,26 @@ | |
| 88 | } |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | p->a[i].id = e; |
| 93 | p->a[i].p = pData; |
| 94 | p->a[i].value = v; |
| 95 | p->cnt++; |
| 96 | } |
| 97 | |
| 98 | /* |
| 99 | ** Extract the first element from the queue (the element with |
| 100 | ** the smallest value) and return its ID. Return 0 if the queue |
| 101 | ** is empty. |
| 102 | */ |
| 103 | int pqueuex_extract(PQueue *p, void **pp){ |
| 104 | int e, i; |
| 105 | if( p->cnt==0 ){ |
| 106 | if( pp ) *pp = 0; |
| 107 | return 0; |
| 108 | } |
| 109 | e = p->a[0].id; |
| 110 | if( pp ) *pp = p->a[0].p; |
| 111 | for(i=0; i<p->cnt-1; i++){ |
| 112 | p->a[i] = p->a[i+1]; |
| 113 | } |
| 114 | p->cnt--; |
| 115 | return e; |
| 116 | } |
| 117 |
| --- src/pqueue.c | |
| +++ src/pqueue.c | |
| @@ -42,11 +42,10 @@ | |
| 42 | struct PQueue { |
| 43 | int cnt; /* Number of entries in the queue */ |
| 44 | int sz; /* Number of slots in a[] */ |
| 45 | struct QueueElement { |
| 46 | int id; /* ID of the element */ |
| 47 | double value; /* Value of element. Kept in ascending order */ |
| 48 | } *a; |
| 49 | }; |
| 50 | #endif |
| 51 | |
| @@ -74,11 +73,11 @@ | |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | ** Insert element e into the queue. |
| 77 | */ |
| 78 | void pqueuex_insert(PQueue *p, int e, double v){ |
| 79 | int i, j; |
| 80 | if( p->cnt+1>p->sz ){ |
| 81 | pqueuex_resize(p, p->cnt+5); |
| 82 | } |
| 83 | for(i=0; i<p->cnt; i++){ |
| @@ -88,29 +87,26 @@ | |
| 87 | } |
| 88 | break; |
| 89 | } |
| 90 | } |
| 91 | p->a[i].id = e; |
| 92 | p->a[i].value = v; |
| 93 | p->cnt++; |
| 94 | } |
| 95 | |
| 96 | /* |
| 97 | ** Extract the first element from the queue (the element with |
| 98 | ** the smallest value) and return its ID. Return 0 if the queue |
| 99 | ** is empty. |
| 100 | */ |
| 101 | int pqueuex_extract(PQueue *p){ |
| 102 | int e, i; |
| 103 | if( p->cnt==0 ){ |
| 104 | return 0; |
| 105 | } |
| 106 | e = p->a[0].id; |
| 107 | for(i=0; i<p->cnt-1; i++){ |
| 108 | p->a[i] = p->a[i+1]; |
| 109 | } |
| 110 | p->cnt--; |
| 111 | return e; |
| 112 | } |
| 113 |
+3
-3
| --- src/tag.c | ||
| +++ src/tag.c | ||
| @@ -44,11 +44,11 @@ | ||
| 44 | 44 | Stmt ins; /* INSERT INTO tagxref */ |
| 45 | 45 | Stmt eventupdate; /* UPDATE event */ |
| 46 | 46 | |
| 47 | 47 | assert( tagType==0 || tagType==2 ); |
| 48 | 48 | pqueuex_init(&queue); |
| 49 | - pqueuex_insert(&queue, pid, 0.0, 0); | |
| 49 | + pqueuex_insert(&queue, pid, 0.0); | |
| 50 | 50 | |
| 51 | 51 | /* Query for children of :pid to which to propagate the tag. |
| 52 | 52 | ** Three returns: (1) rid of the child. (2) timestamp of child. |
| 53 | 53 | ** (3) True to propagate or false to block. |
| 54 | 54 | */ |
| @@ -79,18 +79,18 @@ | ||
| 79 | 79 | if( tagid==TAG_BGCOLOR ){ |
| 80 | 80 | db_prepare(&eventupdate, |
| 81 | 81 | "UPDATE event SET bgcolor=%Q WHERE objid=:rid", zValue |
| 82 | 82 | ); |
| 83 | 83 | } |
| 84 | - while( (pid = pqueuex_extract(&queue, 0))!=0 ){ | |
| 84 | + while( (pid = pqueuex_extract(&queue))!=0 ){ | |
| 85 | 85 | db_bind_int(&s, ":pid", pid); |
| 86 | 86 | while( db_step(&s)==SQLITE_ROW ){ |
| 87 | 87 | int doit = db_column_int(&s, 2); |
| 88 | 88 | if( doit ){ |
| 89 | 89 | int cid = db_column_int(&s, 0); |
| 90 | 90 | double mtime = db_column_double(&s, 1); |
| 91 | - pqueuex_insert(&queue, cid, mtime, 0); | |
| 91 | + pqueuex_insert(&queue, cid, mtime); | |
| 92 | 92 | db_bind_int(&ins, ":rid", cid); |
| 93 | 93 | db_step(&ins); |
| 94 | 94 | db_reset(&ins); |
| 95 | 95 | if( tagid==TAG_BGCOLOR ){ |
| 96 | 96 | db_bind_int(&eventupdate, ":rid", cid); |
| 97 | 97 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -44,11 +44,11 @@ | |
| 44 | Stmt ins; /* INSERT INTO tagxref */ |
| 45 | Stmt eventupdate; /* UPDATE event */ |
| 46 | |
| 47 | assert( tagType==0 || tagType==2 ); |
| 48 | pqueuex_init(&queue); |
| 49 | pqueuex_insert(&queue, pid, 0.0, 0); |
| 50 | |
| 51 | /* Query for children of :pid to which to propagate the tag. |
| 52 | ** Three returns: (1) rid of the child. (2) timestamp of child. |
| 53 | ** (3) True to propagate or false to block. |
| 54 | */ |
| @@ -79,18 +79,18 @@ | |
| 79 | if( tagid==TAG_BGCOLOR ){ |
| 80 | db_prepare(&eventupdate, |
| 81 | "UPDATE event SET bgcolor=%Q WHERE objid=:rid", zValue |
| 82 | ); |
| 83 | } |
| 84 | while( (pid = pqueuex_extract(&queue, 0))!=0 ){ |
| 85 | db_bind_int(&s, ":pid", pid); |
| 86 | while( db_step(&s)==SQLITE_ROW ){ |
| 87 | int doit = db_column_int(&s, 2); |
| 88 | if( doit ){ |
| 89 | int cid = db_column_int(&s, 0); |
| 90 | double mtime = db_column_double(&s, 1); |
| 91 | pqueuex_insert(&queue, cid, mtime, 0); |
| 92 | db_bind_int(&ins, ":rid", cid); |
| 93 | db_step(&ins); |
| 94 | db_reset(&ins); |
| 95 | if( tagid==TAG_BGCOLOR ){ |
| 96 | db_bind_int(&eventupdate, ":rid", cid); |
| 97 |
| --- src/tag.c | |
| +++ src/tag.c | |
| @@ -44,11 +44,11 @@ | |
| 44 | Stmt ins; /* INSERT INTO tagxref */ |
| 45 | Stmt eventupdate; /* UPDATE event */ |
| 46 | |
| 47 | assert( tagType==0 || tagType==2 ); |
| 48 | pqueuex_init(&queue); |
| 49 | pqueuex_insert(&queue, pid, 0.0); |
| 50 | |
| 51 | /* Query for children of :pid to which to propagate the tag. |
| 52 | ** Three returns: (1) rid of the child. (2) timestamp of child. |
| 53 | ** (3) True to propagate or false to block. |
| 54 | */ |
| @@ -79,18 +79,18 @@ | |
| 79 | if( tagid==TAG_BGCOLOR ){ |
| 80 | db_prepare(&eventupdate, |
| 81 | "UPDATE event SET bgcolor=%Q WHERE objid=:rid", zValue |
| 82 | ); |
| 83 | } |
| 84 | while( (pid = pqueuex_extract(&queue))!=0 ){ |
| 85 | db_bind_int(&s, ":pid", pid); |
| 86 | while( db_step(&s)==SQLITE_ROW ){ |
| 87 | int doit = db_column_int(&s, 2); |
| 88 | if( doit ){ |
| 89 | int cid = db_column_int(&s, 0); |
| 90 | double mtime = db_column_double(&s, 1); |
| 91 | pqueuex_insert(&queue, cid, mtime); |
| 92 | db_bind_int(&ins, ":rid", cid); |
| 93 | db_step(&ins); |
| 94 | db_reset(&ins); |
| 95 | if( tagid==TAG_BGCOLOR ){ |
| 96 | db_bind_int(&eventupdate, ":rid", cid); |
| 97 |