Skip to content

Commit 5ca9940

Browse files
committed
Small tweaks to lazy source provider.
1 parent e43eea9 commit 5ca9940

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

rhino/src/main/java/org/mozilla/javascript/LazySourceCodeProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ public LazySourceCodeProvider(SourceCodeSupplier sourceSupplier) {
2020

2121
@Override
2222
public String getSource(String functionName, int start, int end) {
23-
if (sourceCodeRef != null && sourceCodeRef.get() != null) {
24-
String source = sourceCodeRef.get();
23+
String source;
24+
if (sourceCodeRef != null && (source = sourceCodeRef.get()) != null) {
25+
source = sourceCodeRef.get();
2526
return source.substring(start, end);
2627
} else {
27-
String source = sourceSupplier.get();
28+
source = sourceSupplier.get();
2829
sourceCodeRef = new WeakReference<>(source);
2930
if (source != null) {
3031
return source.substring(start, end);

0 commit comments

Comments
 (0)