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

Optimization of string splitting #13812

Merged
merged 1 commit into from Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/babel-code-frame/src/index.ts
Expand Up @@ -147,7 +147,7 @@ export function codeFrameColumns(
const highlightedLines = highlighted ? highlight(rawLines, opts) : rawLines;

let frame = highlightedLines
.split(NEWLINE)
.split(NEWLINE, end)
.slice(start, end)
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need , end here?

Copy link
Contributor Author

@shoonia shoonia Oct 5, 2021

Choose a reason for hiding this comment

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

It's limit for .split(). If we have, supposed, 100 lines and we need to grab from 30 to 34 lines. We know the end line it's a 34, so the .split() creates the first 34 lines and stops.

.map((line, index) => {
const number = start + 1 + index;
Expand Down