Skip to content

Commit

Permalink
Optimize Schema.getGlobalDescribe performance (#78)
Browse files Browse the repository at this point in the history
* Update Query.cls

* Update Query.cls
  • Loading branch information
kratoon authored Feb 15, 2022
1 parent a57863c commit 1c7abe9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/classes/Query.cls
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
*/
public class Query {
public static final String VERSION = '2.0.0-pre';

private static Map<String, SObjectType> globalDescribe {
get {
if (globalDescribe == null) {
globalDescribe = Schema.getGlobalDescribe();
}
return globalDescribe;
}
set;
}

/* Public members */
public Query(String objectName) {
Expand All @@ -32,10 +42,6 @@ public class Query {
public Query(String objectName, String namespace) {
setNamespace(namespace);

// Get Schema.SObjectType
Map<String, Schema.SObjectType> globalDescribe =
Schema.getGlobalDescribe();

this.objectType = globalDescribe.get(appendNamespace(objectName));

if (null == this.objectType) {
Expand Down

0 comments on commit 1c7abe9

Please sign in to comment.