mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-10 14:38:02 -05:00
GP-5867 dwarf: only iterate struct's defined fields
Iterating all fields (defined and undefined) could cause large memory allocation for the result of Structure.getComponents(), plus iterating undefined fields was unnecessary.
This commit is contained in:
@@ -115,14 +115,14 @@ public class DWARFDataTypeConflictHandler extends DataTypeConflictHandler {
|
||||
}
|
||||
|
||||
Map<String, DataTypeComponent> fullComponentsByName = new HashMap<>();
|
||||
for (DataTypeComponent dtc : full.getComponents()) {
|
||||
for (DataTypeComponent dtc : full.getDefinedComponents()) {
|
||||
String name = dtc.getFieldName();
|
||||
if (name == null) {
|
||||
name = dtc.getDefaultFieldName();
|
||||
}
|
||||
fullComponentsByName.put(name, dtc);
|
||||
}
|
||||
for (DataTypeComponent dtc : part.getComponents()) {
|
||||
for (DataTypeComponent dtc : part.getDefinedComponents()) {
|
||||
String name = dtc.getFieldName();
|
||||
if (name == null) {
|
||||
name = dtc.getDefaultFieldName();
|
||||
|
||||
@@ -50,7 +50,7 @@ public class DataTypeGraphComparator {
|
||||
* @param dt2 matching element from the second/right/dest DataType graph
|
||||
* @return false if abort this subtree, true if continue
|
||||
*/
|
||||
public boolean observe(DataType dt1, DataType dt2);
|
||||
boolean observe(DataType dt1, DataType dt2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ public class DataTypeGraphComparator {
|
||||
}
|
||||
|
||||
private void compare(Structure pre, Structure post) {
|
||||
for (DataTypeComponent dtc : pre.getComponents()) {
|
||||
for (DataTypeComponent dtc : pre.getDefinedComponents()) {
|
||||
DataType preDTCType = dtc.getDataType();
|
||||
DataTypeComponent postDTC = post.getComponentAt(dtc.getOffset());
|
||||
if (postDTC == null) {
|
||||
@@ -173,12 +173,12 @@ public class DataTypeGraphComparator {
|
||||
|
||||
private void compare(Union pre, Union post) {
|
||||
Map<String, DataTypeComponent> postCompsByName = new HashMap<>();
|
||||
for (DataTypeComponent dtc : post.getComponents()) {
|
||||
for (DataTypeComponent dtc : post.getDefinedComponents()) {
|
||||
if (dtc.getFieldName() != null) {
|
||||
postCompsByName.put(dtc.getFieldName(), dtc);
|
||||
}
|
||||
}
|
||||
for (DataTypeComponent preDTC : pre.getComponents()) {
|
||||
for (DataTypeComponent preDTC : pre.getDefinedComponents()) {
|
||||
DataTypeComponent postDTC = postCompsByName.get(preDTC.getFieldName());
|
||||
if (postDTC != null) {
|
||||
compare(preDTC.getDataType(), postDTC.getDataType());
|
||||
|
||||
Reference in New Issue
Block a user