@@ -13,11 +13,14 @@ public static T GetAndCache<T>(
13
13
ref T cachedObject )
14
14
{
15
15
cache . CheckFeaturesRevision ( ) ;
16
- if ( cachedObject == null )
16
+
17
+ T obj = cachedObject ;
18
+ if ( obj == null )
17
19
{
18
- cachedObject = features . Get < T > ( ) ;
20
+ obj = features . Get < T > ( ) ;
21
+ cachedObject = obj ;
19
22
}
20
- return cachedObject ;
23
+ return obj ;
21
24
}
22
25
23
26
public static T GetOrCreateAndCache < T > (
@@ -27,16 +30,19 @@ public static T GetOrCreateAndCache<T>(
27
30
ref T cachedObject )
28
31
{
29
32
cache . CheckFeaturesRevision ( ) ;
30
- if ( cachedObject == null )
33
+
34
+ T obj = cachedObject ;
35
+ if ( obj == null )
31
36
{
32
- cachedObject = features . Get < T > ( ) ;
33
- if ( cachedObject == null )
37
+ obj = features . Get < T > ( ) ;
38
+ if ( obj == null )
34
39
{
35
- cachedObject = factory ( ) ;
36
- features . Set ( cachedObject ) ;
40
+ obj = factory ( ) ;
41
+ cachedObject = obj ;
42
+ features . Set ( obj ) ;
37
43
}
38
44
}
39
- return cachedObject ;
45
+ return obj ;
40
46
}
41
47
42
48
public static T GetOrCreateAndCache < T > (
@@ -46,16 +52,19 @@ public static T GetOrCreateAndCache<T>(
46
52
ref T cachedObject )
47
53
{
48
54
cache . CheckFeaturesRevision ( ) ;
49
- if ( cachedObject == null )
55
+
56
+ T obj = cachedObject ;
57
+ if ( obj == null )
50
58
{
51
- cachedObject = features . Get < T > ( ) ;
52
- if ( cachedObject == null )
59
+ obj = features . Get < T > ( ) ;
60
+ if ( obj == null )
53
61
{
54
- cachedObject = factory ( features ) ;
55
- features . Set ( cachedObject ) ;
62
+ obj = factory ( features ) ;
63
+ cachedObject = obj ;
64
+ features . Set ( obj ) ;
56
65
}
57
66
}
58
- return cachedObject ;
67
+ return obj ;
59
68
}
60
69
61
70
public static T GetOrCreateAndCache < T > (
@@ -66,16 +75,19 @@ public static T GetOrCreateAndCache<T>(
66
75
ref T cachedObject )
67
76
{
68
77
cache . CheckFeaturesRevision ( ) ;
69
- if ( cachedObject == null )
78
+
79
+ T obj = cachedObject ;
80
+ if ( obj == null )
70
81
{
71
- cachedObject = features . Get < T > ( ) ;
72
- if ( cachedObject == null )
82
+ obj = features . Get < T > ( ) ;
83
+ if ( obj == null )
73
84
{
74
- cachedObject = factory ( request ) ;
75
- features . Set ( cachedObject ) ;
85
+ obj = factory ( request ) ;
86
+ cachedObject = obj ;
87
+ features . Set ( obj ) ;
76
88
}
77
89
}
78
- return cachedObject ;
90
+ return obj ;
79
91
}
80
92
}
81
93
}
0 commit comments