mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
gpg: Improve import slowness.
* g10/import.c (read_block): Avoid O(N^2) append. (sec_to_pub_keyblock): Likewise. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
a7a043e825
commit
33c17a8008
18
g10/import.c
18
g10/import.c
@ -864,6 +864,7 @@ read_block( IOBUF a, unsigned int options,
|
|||||||
struct parse_packet_ctx_s parsectx;
|
struct parse_packet_ctx_s parsectx;
|
||||||
PACKET *pkt;
|
PACKET *pkt;
|
||||||
kbnode_t root = NULL;
|
kbnode_t root = NULL;
|
||||||
|
kbnode_t lastnode = NULL;
|
||||||
int in_cert, in_v3key, skip_sigs;
|
int in_cert, in_v3key, skip_sigs;
|
||||||
u32 keyid[2];
|
u32 keyid[2];
|
||||||
int got_keyid = 0;
|
int got_keyid = 0;
|
||||||
@ -873,7 +874,7 @@ read_block( IOBUF a, unsigned int options,
|
|||||||
|
|
||||||
if (*pending_pkt)
|
if (*pending_pkt)
|
||||||
{
|
{
|
||||||
root = new_kbnode( *pending_pkt );
|
root = lastnode = new_kbnode( *pending_pkt );
|
||||||
*pending_pkt = NULL;
|
*pending_pkt = NULL;
|
||||||
log_assert (root->pkt->pkttype == PKT_PUBLIC_KEY
|
log_assert (root->pkt->pkttype == PKT_PUBLIC_KEY
|
||||||
|| root->pkt->pkttype == PKT_SECRET_KEY);
|
|| root->pkt->pkttype == PKT_SECRET_KEY);
|
||||||
@ -1041,9 +1042,12 @@ read_block( IOBUF a, unsigned int options,
|
|||||||
if (in_cert && valid_keyblock_packet (pkt->pkttype))
|
if (in_cert && valid_keyblock_packet (pkt->pkttype))
|
||||||
{
|
{
|
||||||
if (!root )
|
if (!root )
|
||||||
root = new_kbnode (pkt);
|
root = lastnode = new_kbnode (pkt);
|
||||||
else
|
else
|
||||||
add_kbnode (root, new_kbnode (pkt));
|
{
|
||||||
|
lastnode->next = new_kbnode (pkt);
|
||||||
|
lastnode = lastnode->next;
|
||||||
|
}
|
||||||
pkt = xmalloc (sizeof *pkt);
|
pkt = xmalloc (sizeof *pkt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2664,6 +2668,7 @@ sec_to_pub_keyblock (kbnode_t sec_keyblock)
|
|||||||
kbnode_t pub_keyblock = NULL;
|
kbnode_t pub_keyblock = NULL;
|
||||||
kbnode_t ctx = NULL;
|
kbnode_t ctx = NULL;
|
||||||
kbnode_t secnode, pubnode;
|
kbnode_t secnode, pubnode;
|
||||||
|
kbnode_t lastnode = NULL;
|
||||||
unsigned int tag = 0;
|
unsigned int tag = 0;
|
||||||
|
|
||||||
/* Set a tag to all nodes. */
|
/* Set a tag to all nodes. */
|
||||||
@ -2703,9 +2708,12 @@ sec_to_pub_keyblock (kbnode_t sec_keyblock)
|
|||||||
pubnode->tag = secnode->tag;
|
pubnode->tag = secnode->tag;
|
||||||
|
|
||||||
if (!pub_keyblock)
|
if (!pub_keyblock)
|
||||||
pub_keyblock = pubnode;
|
pub_keyblock = lastnode = pubnode;
|
||||||
else
|
else
|
||||||
add_kbnode (pub_keyblock, pubnode);
|
{
|
||||||
|
lastnode->next = pubnode;
|
||||||
|
lastnode = pubnode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pub_keyblock;
|
return pub_keyblock;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user