Avoid some redundant calls to time(NULL).

touch_key() must not be called in create_key.
This commit is contained in:
Alexandre Julliard 2003-02-25 04:04:18 +00:00
parent c509bc4d0d
commit 4378d25bd2
1 changed files with 5 additions and 4 deletions

View File

@ -663,7 +663,6 @@ static struct key *create_key( struct key *key, WCHAR *name, WCHAR *class,
if (!*path) goto done; if (!*path) goto done;
*created = 1; *created = 1;
touch_key( key, REG_NOTIFY_CHANGE_NAME ); /* FIXME: is this right? */
if (flags & KEY_DIRTY) make_dirty( key ); if (flags & KEY_DIRTY) make_dirty( key );
base = key; base = key;
base_idx = index; base_idx = index;
@ -1201,7 +1200,8 @@ static int get_data_type( const char *buffer, int *type, int *parse_type )
/* load and create a key from the input file */ /* load and create a key from the input file */
static struct key *load_key( struct key *base, const char *buffer, int flags, static struct key *load_key( struct key *base, const char *buffer, int flags,
int prefix_len, struct file_load_info *info ) int prefix_len, struct file_load_info *info,
int default_modif )
{ {
WCHAR *p, *name; WCHAR *p, *name;
int res, len, modif; int res, len, modif;
@ -1214,7 +1214,7 @@ static struct key *load_key( struct key *base, const char *buffer, int flags,
file_read_error( "Malformed key", info ); file_read_error( "Malformed key", info );
return NULL; return NULL;
} }
if (sscanf( buffer + res, " %d", &modif ) != 1) modif = time(NULL); if (sscanf( buffer + res, " %d", &modif ) != 1) modif = default_modif;
p = (WCHAR *)info->tmp; p = (WCHAR *)info->tmp;
while (prefix_len && *p) { if (*p++ == '\\') prefix_len--; } while (prefix_len && *p) { if (*p++ == '\\') prefix_len--; }
@ -1388,6 +1388,7 @@ static void load_keys( struct key *key, FILE *f )
struct key *subkey = NULL; struct key *subkey = NULL;
struct file_load_info info; struct file_load_info info;
char *p; char *p;
int default_modif = time(NULL);
int flags = (key->flags & KEY_VOLATILE) ? KEY_VOLATILE : KEY_DIRTY; int flags = (key->flags & KEY_VOLATILE) ? KEY_VOLATILE : KEY_DIRTY;
int prefix_len = -1; /* number of key name prefixes to skip */ int prefix_len = -1; /* number of key name prefixes to skip */
@ -1418,7 +1419,7 @@ static void load_keys( struct key *key, FILE *f )
case '[': /* new key */ case '[': /* new key */
if (subkey) release_object( subkey ); if (subkey) release_object( subkey );
if (prefix_len == -1) prefix_len = get_prefix_len( key, p + 1, &info ); if (prefix_len == -1) prefix_len = get_prefix_len( key, p + 1, &info );
if (!(subkey = load_key( key, p + 1, flags, prefix_len, &info ))) if (!(subkey = load_key( key, p + 1, flags, prefix_len, &info, default_modif )))
file_read_error( "Error creating key", &info ); file_read_error( "Error creating key", &info );
break; break;
case '@': /* default value */ case '@': /* default value */