box: unify key_def constructing procedure
Currently, there are two ways of creating a new key definition object apart from copying (key_def_dup): either use key_def_new_with_parts, which takes definition of all key parts and returns a ready to use key_def, or allocate an empty key_def with key_def_new and then fill it up with key_def_set_part. The latter method is rather awkward: because of its existence key_def_set_part has to detect if all parts have been set and initialize comparators if so. It is only used in schema_init, which could as well use key_def_new_with_parts without making the code any more difficult to read than it is now. That being said, let us: - Make schema_init use key_def_new_with_parts. - Delete key_def_new and bequeath its name to key_def_new_with_parts. - Simplify key_def_set_part: now it only initializes the given part while comparators are set by the caller once all parts have been set. These changes should also make it easier to add json path to key_part.
Showing
- src/box/alter.cc 1 addition, 1 deletionsrc/box/alter.cc
- src/box/key_def.c 36 additions, 51 deletionssrc/box/key_def.c
- src/box/key_def.h 3 additions, 16 deletionssrc/box/key_def.h
- src/box/schema.cc 37 additions, 37 deletionssrc/box/schema.cc
- src/box/vinyl.c 2 additions, 2 deletionssrc/box/vinyl.c
Loading
Please register or sign in to comment