Skip to content

Commit

Permalink
apply recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinmombay committed Nov 3, 2016
1 parent 9f6e95e commit 5f8d2e5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
Binary file modified build-system/runner/dist/runner.jar
Binary file not shown.
7 changes: 2 additions & 5 deletions build-system/runner/src/org/ampproject/AmpPass.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class AmpPass extends AbstractPostOrderCallback implements HotSwapCompilerPass {
private final Map<String, Node> prodAssignmentReplacements;
final boolean isProd;

final Integer ampExtensionCallbackPosition = 4;

public AmpPass(AbstractCompiler compiler, boolean isProd,
Map<String, Set<String>> stripTypeSuffixes,
Map<String, Node> assignmentReplacements, Map<String, Node> prodAssignmentReplacements) {
Expand Down Expand Up @@ -106,7 +104,7 @@ public AmpPass(AbstractCompiler compiler, boolean isProd,
* FUNCTION 3 [length: 46] [source_file: input0]
*/
private boolean isAmpExtensionCall(Node n) {
if (n != null && n.isCall() && n.getChildCount() == ampExtensionCallbackPosition) {
if (n != null && n.isCall()) {
Node getprop = n.getFirstChild();

// The AST has the last getprop higher in the hierarchy.
Expand Down Expand Up @@ -164,8 +162,7 @@ private void inlineAmpExtensionCall(Node n, Node expr) {
}

private Node getAmpExtensionCallback(Node n) {
// 0 index based
return n.getChildAtIndex(ampExtensionCallbackPosition - 1);
return n.getLastChild();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function adoptShared(global, opts, callback) {
// as `AMP.push()` in production.
// TODO(dvoytenko, #5507): Only expose this method for `!getMode().minified`
// once the compile-time inlining is done.
if (!global.AMP.extension) {
if (!getMode().minified) {
/**
* @param {string} unusedName
* @param {string} unusedVersion
Expand Down
14 changes: 6 additions & 8 deletions testing/describes.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,12 @@ class AmpFixture {
// Thus, not changes needed here.
}
if (spec.extensions) {
spec.extensions.forEach(extensionId => {
let bufferId = extensionId;
if (extensionId.indexOf(':') == -1) {
// We default to 0.1 if the user did not give an explicit
// version.
bufferId = `${extensionId}:0.1`;
}
const installer = extensionsBuffer[bufferId];
spec.extensions.forEach(extensionIdWithVersion => {
const tuple = extensionIdWithVersion.split(':');
const extensionId = tuple[0];
// Default to 0.1 if no version was provided.
const version = tuple[1] || '0.1';
const installer = extensionsBuffer[`${extensionId}:${version}`];
if (installer) {
installer(win.AMP);
} else {
Expand Down

0 comments on commit 5f8d2e5

Please sign in to comment.