1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[TableGen] Reduce the number of map lookups in TypeSetByHwMode::getOrCreate. NFCI

hasMode was looking up the map once. Then we'd either call get which
would look up again, or we'd insert into the map which requires
walking the map to find the insertion point.

I believe the hasMode was needed because get has a special case
to look for DefaultMode if the mode being asked for doesn't exist.
We don't want that here so we were using hasMode to make sure we
wouldn't hit that case.

Simplify to a regular operator[] access which will default
construct a SetType if the lookup fails.
This commit is contained in:
Craig Topper 2021-04-15 12:24:47 -07:00
parent e718ff5dc3
commit 6b675e5ab5

View File

@ -200,9 +200,7 @@ struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {
TypeSetByHwMode(ArrayRef<ValueTypeByHwMode> VTList); TypeSetByHwMode(ArrayRef<ValueTypeByHwMode> VTList);
SetType &getOrCreate(unsigned Mode) { SetType &getOrCreate(unsigned Mode) {
if (hasMode(Mode)) return Map[Mode];
return get(Mode);
return Map.insert({Mode,SetType()}).first->second;
} }
bool isValueTypeByHwMode(bool AllowEmpty) const; bool isValueTypeByHwMode(bool AllowEmpty) const;