Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove redundant variables from deser functions #1153

Merged
merged 9 commits into from
May 5, 2020

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented May 5, 2020

Issue #, if available:

Description of changes:
Removes the following redundant variables from deser functions:

  • contents
  • wrappedItem
  • mapParams

Sample code:

  • contents:
    • Before
      const deserializeAws_restXmlStructureList = (
        output: any,
        context: __SerdeContext
      ): StructureListMember[] => {
        const contents: any = [];
        (output || []).map((entry: any) => {
          contents.push(deserializeAws_restXmlStructureListMember(entry, context));
        });
        return contents;
      };
    • After
      const deserializeAws_restXmlStructureList = (
        output: any,
        context: __SerdeContext
      ): StructureListMember[] => {
        return (output || []).map((entry: any) =>
          deserializeAws_restXmlStructureListMember(entry, context)
        );
      };
  • wrappedItem:
    • Before
      const deserializeAws_restXmlNestedStringList = (
        output: any,
        context: __SerdeContext
      ): string[][] => {
        const contents: any = [];
        (output || []).map((entry: any) => {
          const wrappedItem =
            entry["member"] instanceof Array ? entry["member"] : [entry["member"]];
          contents.push(deserializeAws_restXmlStringList(wrappedItem, context));
        });
        return contents;
      };
    • After
      const deserializeAws_restXmlNestedStringList = (
        output: any,
        context: __SerdeContext
      ): string[][] => {
        return (output || []).map((entry: any) =>
          deserializeAws_restXmlStringList(
            __getArrayIfSingleItem(entry["member"]),
            context
          )
        );
      };
  • mapParams:
    • Before
      const deserializeAws_restXmlXmlMapsInputOutputMap = (
        output: any,
        context: __SerdeContext
      ): { [key: string]: GreetingStruct } => {
        const mapParams: any = {};
        output.forEach((pair: any) => {
          mapParams[pair["key"]] = deserializeAws_restXmlGreetingStruct(
            pair["value"],
            context
          );
        });
        return mapParams;
      };
    • After
      const deserializeAws_restXmlXmlMapsInputOutputMap = (
        output: any,
        context: __SerdeContext
      ): { [key: string]: GreetingStruct } => {
        return output.reduce((acc: any, pair: any) => {
          acc[pair["key"]] = deserializeAws_restXmlGreetingStruct(
            pair["value"],
            context
          );
          return acc;
        }, {});
      };

Verified that integration tests are successful:

$ AWS_PROFILE=<profile> yarn test:integration
yarn run v1.22.4
$ cucumber-js --fail-fast
.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

153 scenarios (153 passed)
534 steps (534 passed)
0m54.796s
Done in 57.63s.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 825a28a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the optimizations! Looks good to me from JS side

@lock
Copy link

lock bot commented May 20, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export instanceof Array check to a utility function
3 participants