This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/4] gdb/riscv: Create each unique target description only once


On 11/29/2018 04:48 PM, Andrew Burgess wrote:

> +
> +  /* Add TDESC into the cache, a target description created to match
> +     FEATURES.  */
> +  void add (const struct riscv_gdbarch_features features,
> +            const target_desc *tdesc)
> +  {
> +    feature_tdesc_pair p (features, tdesc);
> +    m_tdesc_list.push_back (p);
> +  }
> +
> +private:
> +
> +  /* Map from a feature set to the corresponding target description.  */
> +  typedef std::pair<const struct riscv_gdbarch_features,
> +                    const target_desc *> feature_tdesc_pair;
> +
> +  /* List of all target descriptions we've previously seen.  */
> +  std::vector<feature_tdesc_pair> m_tdesc_list;
> +};

Did you consider an unordered_map instead of this whole class here?
See xml-tdesc.c's xml_cache.  If there's a reason the custom data
structure is preferred, I think that warrants a comment.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]