"ZheNing Hu via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes: > From: ZheNing Hu <adlternative@xxxxxxxxx> > > Since "objectsize:size" is composed of two parts, > "type:attribute". However, the original implementation Y is missing in the above "Since X, Y". Because it is composed of two parts, what? Dropping "Since " would make the sentence work better. Also, I think it should be "objectsize:disk". > did not decouple the two parts "type" and "attribute" well, > we still need to judge separately whether the atom is > "objectsize" or "objectsize:disk" in `grab_common_values()`. Perhaps When the support for "objectsize:disk" was bolted onto the existing support for "objectsize", it didn't follow the usual pattern for handling "atomtype:modifier", which reads the <modifier> part just once while parsing the format string, and store the parsed result in the union in the used_atom structure, so that the string form of it does not have to be parsed over and over at runtime (e.g. in grab_common_values()). > Add a new member `objectsize` to the union `used_atom.u`, > so that we can separate the judgment of atom type from the > judgment of atom attribute, This will bring scalability to > atom `%(objectsize)`. OK. > + struct { > + enum { O_SIZE, O_SIZE_DISK } option; > + } objectsize; OK. > @@ -967,12 +972,14 @@ static void grab_common_values(struct atom_value *val, int deref, struct expand_ > name++; > if (!strcmp(name, "objecttype")) > v->s = xstrdup(type_name(oi->type)); > + else if (starts_with(name, "objectsize")) { > + if (used_atom[i].u.objectsize.option == O_SIZE_DISK) { > + v->value = oi->disk_size; > + v->s = xstrfmt("%"PRIuMAX, (uintmax_t)oi->disk_size); > + } else if (used_atom[i].u.objectsize.option == O_SIZE) { > + v->value = oi->size; > + v->s = xstrfmt("%"PRIuMAX , (uintmax_t)oi->size); > + } OK.