Skip to content

Commit

Permalink
Source.getString tightening
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Apr 8, 2021
1 parent 894a6c4 commit b2c4c70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void setParent(final RecompilableScriptFunctionData parent) {
@Override
String toSource() {
if (source != null && token != 0) {
return source.getString(Token.descPosition(token), Token.descLength(token));
return source.getString(token);
}

return "function " + (name == null ? "" : name) + "() { [native code] }";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,7 @@ public String getString(final int start, final int len) {
* @return Source content portion.
*/
public String getString(final long token) {
final int start = Token.descPosition(token);
final int len = Token.descLength(token);
return new String(data(), start, len);
return getString(Token.descPosition(token), Token.descLength(token));
}

/**
Expand Down Expand Up @@ -738,7 +736,7 @@ public String getSourceLine(final int position) {
// Find end of this line.
final int last = findEOLN(position);

return new String(data(), first, last - first + 1);
return getString(first, last - first + 1);
}

/**
Expand Down

0 comments on commit b2c4c70

Please sign in to comment.