-
Notifications
You must be signed in to change notification settings - Fork 901
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
Refactor copying query result to clipboard #25152
Refactor copying query result to clipboard #25152
Conversation
@microsoft-github-policy-service agree |
Pull Request Test Coverage Report for Build 7342499286
💛 - Coveralls |
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.
I'm pretty surprised that using reduce has that much of an impact. What kind of timing improvements were you seeing? i.e. with the same result data what was the time to copy with the original implementation vs what you have now?
@@ -133,7 +133,7 @@ export async function copySelectionToClipboard(clipboardService: IClipboardServi | |||
const getMessageText = (): string => { | |||
return nls.localize('gridDataProvider.loadingRowsInProgress', "Loading the rows to be copied ({0}/{1})...", processedRows, rowCount); | |||
}; | |||
let resultString = ''; | |||
let headerString = ''; |
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.
nit: Instead of making a whole separate var and copying that into the array you create below I'd suggest just creating the array here and push the header to it directly on line 145.
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.
Yeah, I guess I could do that but I wanted the logic of string-join to be separated from the logic of creating the data rows.
@serhat359 thanks for the PR, could you please update the PR description to include the perf improvements? e.g. rows, columns, time taken before, time taken after |
@alanrenmsft I added a table to the description that shows the performance improvements. |
@serhat359 thanks! |
When would this fix be merged to the main branch? |
Closes the issue #24901
Makes copying table result to clipboard faster by using a StringBuilder (JS/TS implementation).
I've locally tested before and after versions of the function with different inputs to make sure the new function behaves the same as before.
You can see the performance results comparing before and after below. Each data row contains 4 columns ('foo', 'bar', 'baz', row index). SkipNewLine means the variable
shouldSkipNewLineAfterTrailingLineBreak
config setting in the code.