@@ -49,14 +49,16 @@ inline PortDirection from_string_to_port_dir(const std::string& port_type) {
4949class TimingObjectDatabase {
5050 private:
5151 // / @brief A mapping between an object ID and its name.
52- std::unordered_map<ObjectId, std::string> object_name_;
52+ std::vector< std::string> object_name_;
5353 // / @brief A mapping between an object ID and its type.
54- std::unordered_map<ObjectId, ObjectType> object_type_;
54+ std::vector< ObjectType> object_type_;
5555 // / @brief A mapping between a port object and its direction.
5656 std::unordered_map<ObjectId, PortDirection> port_direction_;
5757 // / @brief A collection of all clock driver objects.
5858 std::vector<ObjectId> clock_driver_objects_;
5959
60+ // / @brief A collection of all objects that have been created.
61+ // / This is used to create the IDs.
6062 std::vector<ObjectId> all_objects_;
6163
6264 // / @brief A collection of all cell objects.
@@ -86,10 +88,8 @@ class TimingObjectDatabase {
8688 inline ObjectId create_cell_object (const std::string& cell_name) {
8789 ObjectId cell_object_id = ObjectId (all_objects_.size ());
8890 all_objects_.push_back (cell_object_id);
89- assert (object_name_.count (cell_object_id) == 0 );
90- object_name_[cell_object_id] = cell_name;
91- assert (object_type_.count (cell_object_id) == 0 );
92- object_type_[cell_object_id] = ObjectType::Cell;
91+ object_name_.push_back (cell_name);
92+ object_type_.push_back (ObjectType::Cell);
9393 cell_objects.push_back (cell_object_id);
9494 return cell_object_id;
9595 }
@@ -105,10 +105,8 @@ class TimingObjectDatabase {
105105 inline ObjectId create_clock_object (const std::string& clock_name) {
106106 ObjectId clock_object_id = ObjectId (all_objects_.size ());
107107 all_objects_.push_back (clock_object_id);
108- assert (object_name_.count (clock_object_id) == 0 );
109- object_name_[clock_object_id] = clock_name;
110- assert (object_type_.count (clock_object_id) == 0 );
111- object_type_[clock_object_id] = ObjectType::Clock;
108+ object_name_.push_back (clock_name);
109+ object_type_.push_back (ObjectType::Clock);
112110 clock_objects.push_back (clock_object_id);
113111 return clock_object_id;
114112 }
@@ -126,15 +124,13 @@ class TimingObjectDatabase {
126124 * @return The ID of the created object.
127125 */
128126 inline ObjectId create_port_object (const std::string& port_name,
129- PortDirection port_direction,
130- bool is_clock_driver) {
127+ PortDirection port_direction,
128+ bool is_clock_driver) {
131129 assert (port_direction != PortDirection::UNKNOWN);
132130 ObjectId port_object_id = ObjectId (all_objects_.size ());
133131 all_objects_.push_back (port_object_id);
134- assert (object_name_.count (port_object_id) == 0 );
135- object_name_[port_object_id] = port_name;
136- assert (object_type_.count (port_object_id) == 0 );
137- object_type_[port_object_id] = ObjectType::Port;
132+ object_name_.push_back (port_name);
133+ object_type_.push_back (ObjectType::Port);
138134 port_direction_[port_object_id] = port_direction;
139135 port_objects.push_back (port_object_id);
140136 if (port_direction == PortDirection::INPUT || port_direction == PortDirection::INOUT)
@@ -160,13 +156,11 @@ class TimingObjectDatabase {
160156 * @return The ID of the created object.
161157 */
162158 inline ObjectId create_pin_object (const std::string& pin_name,
163- bool is_clock_driver) {
159+ bool is_clock_driver) {
164160 ObjectId pin_object_id = ObjectId (all_objects_.size ());
165161 all_objects_.push_back (pin_object_id);
166- assert (object_name_.count (pin_object_id) == 0 );
167- object_name_[pin_object_id] = pin_name;
168- assert (object_type_.count (pin_object_id) == 0 );
169- object_type_[pin_object_id] = ObjectType::Pin;
162+ object_name_.push_back (pin_name);
163+ object_type_.push_back (ObjectType::Pin);
170164 pin_objects.push_back (pin_object_id);
171165
172166 if (is_clock_driver) {
@@ -187,10 +181,8 @@ class TimingObjectDatabase {
187181 inline ObjectId create_net_object (const std::string& net_name) {
188182 ObjectId net_object_id = ObjectId (all_objects_.size ());
189183 all_objects_.push_back (net_object_id);
190- assert (object_name_.count (net_object_id) == 0 );
191- object_name_[net_object_id] = net_name;
192- assert (object_type_.count (net_object_id) == 0 );
193- object_type_[net_object_id] = ObjectType::Net;
184+ object_name_.push_back (net_name);
185+ object_type_.push_back (ObjectType::Net);
194186 net_objects.push_back (net_object_id);
195187
196188 return net_object_id;
@@ -199,20 +191,22 @@ class TimingObjectDatabase {
199191 /* *
200192 * @brief Get the type of the given object ID.
201193 */
202- inline ObjectType get_object_type (const ObjectId& object_id) {
203- auto it = object_type_.find (object_id);
204- if (it != object_type_.end ())
205- return it->second ;
206- return ObjectType::Unknown;
194+ inline ObjectType get_object_type (ObjectId object_id) {
195+ if (!object_id.is_valid ())
196+ return ObjectType::Unknown;
197+ size_t id_val = static_cast <size_t >(object_id);
198+ if (id_val >= object_type_.size ())
199+ return ObjectType::Unknown;
200+ return object_type_[id_val];
207201 }
208202
209203 /* *
210204 * @brief Get the name of the given object.
211205 */
212- const std::string& get_object_name (const ObjectId& object_id) const {
213- auto it = object_name_. find (object_id);
214- assert (it != object_name_.end ());
215- return it-> second ;
206+ const std::string& get_object_name (ObjectId object_id) const {
207+ size_t id_val = static_cast < size_t > (object_id);
208+ assert (object_id. is_valid () && id_val < object_name_.size ());
209+ return object_name_[id_val] ;
216210 }
217211
218212 /* *
0 commit comments