GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — assert: remove code that is never reached by Trott · Pull Request #8132 · nodejs/node

Conversation

@Trott

@Trott Trott commented Aug 16, 2016

Copy link
Copy Markdown
Member
Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

assert

Description of change

The internal function truncate() is only called with the first
argument being the output of util.inspect(). util.inspect() calls
its own internal formatValue() which is guaranteed to return a string.

Therefore, we can remove the check in truncate() that the first
argument is a string as well as code to handle the case where it is not
a string.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Trott
assert: remove code that is never reached
744a931
The internal function `truncate()` is only called with the first
argument being the output of `util.inspect()`. `util.inspect()` calls
its own internal `formatValue()` which is guaranteed to return a string.

Therefore, we can remove the check in `truncate()` that the first
argument is a string as well as code to handle the case where it is not
a string.
@Trott Trott added the assert Issues and PRs related to the assert subsystem. label Aug 16, 2016
@Trott

Trott commented Aug 17, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

https://ci.nodejs.org/job/node-test-pull-request/3703/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Aug 17, 2016

Copy link
Copy Markdown
Member Author

There appears to be some Ci infrastructure issues right now...will try again later, but the results look fine on the hosts that didn't have build issues.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Aug 17, 2016

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yorkie
yorkie reviewed Aug 17, 2016
View reviewed changes
Comment thread lib/assert.js Outdated
} else {
return s;
}
return s.length < n ? s : s.slice(0, n);

@Trott Trott Aug 17, 2016

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Not sure. My guess is it was done this way as a micro-optimization for the common case. Seems like just calling s.slice(0,n) as you suggest would be better.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@estliberitas

estliberitas commented Aug 17, 2016

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott
squash: remove ternary
510c80a
@Trott

Trott commented Aug 17, 2016

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/3710/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Aug 17, 2016

Copy link
Copy Markdown
Member

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

1 similar comment
@cjihrig

cjihrig commented Aug 17, 2016

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott added a commit to Trott/io.js that referenced this pull request Aug 18, 2016
@Trott
assert: remove code that is never reached
2e59cce
The internal function `truncate()` is only called with the first
argument being the output of `util.inspect()`. `util.inspect()` calls
its own internal `formatValue()` which is guaranteed to return a string.

Therefore, we can remove the check in `truncate()` that the first
argument is a string as well as code to handle the case where it is not
a string.

PR-URL: nodejs#8132
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Alexander Makarenko <[email protected]>
Reviewed-By: Yorkie Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@Trott

Trott commented Aug 18, 2016

Copy link
Copy Markdown
Member Author

Landed in 2e59cce

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott Trott closed this Aug 18, 2016
evanlucas pushed a commit that referenced this pull request Aug 24, 2016
@Trott @evanlucas
assert: remove code that is never reached
5bc3119
The internal function `truncate()` is only called with the first
argument being the output of `util.inspect()`. `util.inspect()` calls
its own internal `formatValue()` which is guaranteed to return a string.

Therefore, we can remove the check in `truncate()` that the first
argument is a string as well as code to handle the case where it is not
a string.

PR-URL: #8132
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Alexander Makarenko <[email protected]>
Reviewed-By: Yorkie Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@evanlucas evanlucas mentioned this pull request Aug 24, 2016
2016-08-26, Version 6.5.0 (Current) #8253
Merged
@Trott Trott added the lts-watch-v4.x label Sep 9, 2016
@MylesBorins MylesBorins added land-on-v4.x and removed lts-watch-v4.x labels Oct 10, 2016
MylesBorins pushed a commit that referenced this pull request Oct 10, 2016
@Trott Myles Borins
assert: remove code that is never reached
bc3fa4d
The internal function `truncate()` is only called with the first
argument being the output of `util.inspect()`. `util.inspect()` calls
its own internal `formatValue()` which is guaranteed to return a string.

Therefore, we can remove the check in `truncate()` that the first
argument is a string as well as code to handle the case where it is not
a string.

PR-URL: #8132
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Alexander Makarenko <[email protected]>
Reviewed-By: Yorkie Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
rvagg pushed a commit that referenced this pull request Oct 18, 2016
@Trott @rvagg
assert: remove code that is never reached
6fdcd7a
The internal function `truncate()` is only called with the first
argument being the output of `util.inspect()`. `util.inspect()` calls
its own internal `formatValue()` which is guaranteed to return a string.

Therefore, we can remove the check in `truncate()` that the first
argument is a string as well as code to handle the case where it is not
a string.

PR-URL: #8132
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Alexander Makarenko <[email protected]>
Reviewed-By: Yorkie Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 26, 2016
@Trott @MylesBorins
assert: remove code that is never reached
06a1c9b
The internal function `truncate()` is only called with the first
argument being the output of `util.inspect()`. `util.inspect()` calls
its own internal `formatValue()` which is guaranteed to return a string.

Therefore, we can remove the check in `truncate()` that the first
argument is a string as well as code to handle the case where it is not
a string.

PR-URL: #8132
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Alexander Makarenko <[email protected]>
Reviewed-By: Yorkie Liu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Oct 26, 2016
V4.6.2 proposal #9298
Closed
@Trott
Trott deleted the truncatetruncate branch January 13, 2022 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

assert Issues and PRs related to the assert subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@Trott @targos @estliberitas @jasnell @cjihrig @MylesBorins
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.