mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
252073188e
commit
c4b014a4d0
@ -28,9 +28,11 @@ android {
|
|||||||
lint {
|
lint {
|
||||||
checkDependencies true
|
checkDependencies true
|
||||||
}
|
}
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs << "-Xlint:deprecation"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "com.android.tools.build:gradle:$agp_version"
|
|
||||||
api(fileTree(dir: 'lib', include: ['rhino-*.jar']))
|
api(fileTree(dir: 'lib', include: ['rhino-*.jar']))
|
||||||
}
|
}
|
@ -137,9 +137,8 @@ final class ExternalScriptable implements Scriptable {
|
|||||||
* @return the value of the property (may be null), or NOT_FOUND
|
* @return the value of the property (may be null), or NOT_FOUND
|
||||||
*/
|
*/
|
||||||
public synchronized Object get(int index, Scriptable start) {
|
public synchronized Object get(int index, Scriptable start) {
|
||||||
Integer key = new Integer(index);
|
|
||||||
if (indexedProps.containsKey(index)) {
|
if (indexedProps.containsKey(index)) {
|
||||||
return indexedProps.get(key);
|
return indexedProps.get(index);
|
||||||
} else {
|
} else {
|
||||||
return NOT_FOUND;
|
return NOT_FOUND;
|
||||||
}
|
}
|
||||||
@ -170,8 +169,7 @@ final class ExternalScriptable implements Scriptable {
|
|||||||
* @return true if and only if the property was found in the object
|
* @return true if and only if the property was found in the object
|
||||||
*/
|
*/
|
||||||
public synchronized boolean has(int index, Scriptable start) {
|
public synchronized boolean has(int index, Scriptable start) {
|
||||||
Integer key = new Integer(index);
|
return indexedProps.containsKey(index);
|
||||||
return indexedProps.containsKey(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,7 +209,7 @@ final class ExternalScriptable implements Scriptable {
|
|||||||
public void put(int index, Scriptable start, Object value) {
|
public void put(int index, Scriptable start, Object value) {
|
||||||
if (start == this) {
|
if (start == this) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
indexedProps.put(new Integer(index), value);
|
indexedProps.put(index, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
start.put(index, start, value);
|
start.put(index, start, value);
|
||||||
@ -246,7 +244,7 @@ final class ExternalScriptable implements Scriptable {
|
|||||||
* @param index the numeric index for the property
|
* @param index the numeric index for the property
|
||||||
*/
|
*/
|
||||||
public void delete(int index) {
|
public void delete(int index) {
|
||||||
indexedProps.remove(new Integer(index));
|
indexedProps.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -362,7 +360,7 @@ final class ExternalScriptable implements Scriptable {
|
|||||||
} else {
|
} else {
|
||||||
throw Context.reportRuntimeError(
|
throw Context.reportRuntimeError(
|
||||||
"Invalid JavaScript value of type " +
|
"Invalid JavaScript value of type " +
|
||||||
typeHint.toString());
|
typeHint);
|
||||||
}
|
}
|
||||||
args[0] = hint;
|
args[0] = hint;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public final class JSAdapter implements Scriptable, Function {
|
|||||||
public Object get(int index, Scriptable start) {
|
public Object get(int index, Scriptable start) {
|
||||||
Function func = getAdapteeFunction(GET_PROP);
|
Function func = getAdapteeFunction(GET_PROP);
|
||||||
if (func != null) {
|
if (func != null) {
|
||||||
return call(func, new Object[] { new Integer(index) });
|
return call(func, new Object[] {index});
|
||||||
} else {
|
} else {
|
||||||
start = getAdaptee();
|
start = getAdaptee();
|
||||||
return start.get(index, start);
|
return start.get(index, start);
|
||||||
@ -128,7 +128,7 @@ public final class JSAdapter implements Scriptable, Function {
|
|||||||
public boolean has(int index, Scriptable start) {
|
public boolean has(int index, Scriptable start) {
|
||||||
Function func = getAdapteeFunction(HAS_PROP);
|
Function func = getAdapteeFunction(HAS_PROP);
|
||||||
if (func != null) {
|
if (func != null) {
|
||||||
Object res = call(func, new Object[] { new Integer(index) });
|
Object res = call(func, new Object[] {index});
|
||||||
return Context.toBoolean(res);
|
return Context.toBoolean(res);
|
||||||
} else {
|
} else {
|
||||||
start = getAdaptee();
|
start = getAdaptee();
|
||||||
@ -154,7 +154,7 @@ public final class JSAdapter implements Scriptable, Function {
|
|||||||
if (start == this) {
|
if (start == this) {
|
||||||
Function func = getAdapteeFunction(PUT_PROP);
|
Function func = getAdapteeFunction(PUT_PROP);
|
||||||
if( func != null) {
|
if( func != null) {
|
||||||
call(func, new Object[] { new Integer(index), value });
|
call(func, new Object[] {index, value });
|
||||||
} else {
|
} else {
|
||||||
start = getAdaptee();
|
start = getAdaptee();
|
||||||
start.put(index, start, value);
|
start.put(index, start, value);
|
||||||
@ -176,7 +176,7 @@ public final class JSAdapter implements Scriptable, Function {
|
|||||||
public void delete(int index) {
|
public void delete(int index) {
|
||||||
Function func = getAdapteeFunction(DEL_PROP);
|
Function func = getAdapteeFunction(DEL_PROP);
|
||||||
if (func != null) {
|
if (func != null) {
|
||||||
call(func, new Object[] { new Integer(index) });
|
call(func, new Object[] {index});
|
||||||
} else {
|
} else {
|
||||||
getAdaptee().delete(index);
|
getAdaptee().delete(index);
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ public final class JSAdapter implements Scriptable, Function {
|
|||||||
// map a property id. Property id can only be an Integer or String
|
// map a property id. Property id can only be an Integer or String
|
||||||
private Object mapToId(Object tmp) {
|
private Object mapToId(Object tmp) {
|
||||||
if (tmp instanceof Double) {
|
if (tmp instanceof Double) {
|
||||||
return new Integer(((Double)tmp).intValue());
|
return ((Double) tmp).intValue();
|
||||||
} else {
|
} else {
|
||||||
return Context.toString(tmp);
|
return Context.toString(tmp);
|
||||||
}
|
}
|
||||||
|
@ -398,6 +398,7 @@ public final class RhinoScriptEngine extends AbstractScriptEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
Scriptable scope = getRuntimeScope(context);
|
Scriptable scope = getRuntimeScope(context);
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
Script scr = cx.compileReader(scope, script, fileName, 1, null);
|
Script scr = cx.compileReader(scope, script, fileName, 1, null);
|
||||||
ret = new RhinoCompiledScript(this, scr);
|
ret = new RhinoCompiledScript(this, scr);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user