is there a way to optimize below util functions that retrieves Record Type Developer Name in bulk on Trigger before insert:
public static List<Account> getAccountRecordTypeDeveloperNames(List<Account> accountList){
Set<Id> recordIDs = new Set<Id>();
for (Account a : accountList) {
recordIDs.add(a.Id);
}
List<Account> accountWithRecordTypes = new List<Account>([SELECT Id, RecordType.DeveloperName FROM Account WHERE Id IN :recordIDs]);
return accountWithRecordTypes;
}
I have a similar function for when Trigger is for update as shown below:
public static Map<Id, Account> getAccountRecordTypeDeveloperNames(Map<Id, Account> accountMap){
Map<Id,Account> accountWithRecordTypes = new Map<Id, Account>([SELECT Id, RecordType.DeveloperName FROM Account WHERE Id IN :accountMap.keySet()]);
return accountWithRecordTypes;
}
Any way to optimize both functions or combine them in my class?