File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -85,18 +85,18 @@ type compilation struct {
85
85
// addSource will read in a path and assign it a source index. If
86
86
// it's already been loaded, the cached source is returned.
87
87
func (c * compilation ) addSource (path string ) (int , error ) {
88
- c .sourcesMu .RLock ()
89
- if _ , ok := c .sources [path ]; ok {
90
- defer c .sourcesMu .RUnlock ()
91
- return c .sources [path ], nil
92
- }
93
- c .sourcesMu .RUnlock ()
94
-
95
88
abs , err := filepath .Abs (path )
96
89
if err != nil {
97
90
return 0 , oops .Wrapf (err , "failed to make path absolute: %s" , path )
98
91
}
99
92
93
+ c .sourcesMu .RLock ()
94
+ if _ , ok := c .sources [abs ]; ok {
95
+ defer c .sourcesMu .RUnlock ()
96
+ return c .sources [abs ], nil
97
+ }
98
+ c .sourcesMu .RUnlock ()
99
+
100
100
in , err := ioutil .ReadFile (abs )
101
101
if err != nil {
102
102
return 0 , oops .Wrapf (err , "failed to read file: %s" , path )
You can’t perform that action at this time.
0 commit comments