Optimize addToTree function.#4263
Conversation
src/utils/sources-tree/addToTree.js
Outdated
| @@ -1,5 +1,7 @@ | |||
| // @flow | |||
|
|
|||
| import { parse } from "url"; | |||
There was a problem hiding this comment.
does it make sense to have this in getURL to have one module for URL parsing?
There was a problem hiding this comment.
Not at the moment -- I did not want to affect any other logic that might be "assumed" in the code.
src/utils/sources-tree/addToTree.js
Outdated
|
|
||
| type FindNodeInContentsMatcher = any => number; | ||
| /* | ||
| * Performs a binary search to insert a node into contents. Returns positive |
src/utils/sources-tree/addToTree.js
Outdated
| * Checks if node name matches debugger host/domain. | ||
| */ | ||
| function isExactDomainMatch(part: string, debuggeeHost: string): boolean { | ||
| return part.indexOf("www.") === 0 |
There was a problem hiding this comment.
just curious: why not part.startsWith("www.") ?
There was a problem hiding this comment.
No reason, probably just a habit to support old browsers. Changed to startsWith for readability, since all browsers we support have it.
src/utils/sources-tree/addToTree.js
Outdated
| part: string, | ||
| isDir: boolean, | ||
| debuggeeHost: ?string | ||
| ) { |
There was a problem hiding this comment.
we are always returning a function. One that always returns a number. perhaps we can make that clear from the return type:
function createTreeNodeMatcher(
part: string,
isDir: boolean,
debuggeeHost: ?string
): NodeMatcher {
src/utils/sources-tree/addToTree.js
Outdated
| : part === debuggeeHost; | ||
| } | ||
|
|
||
| type FindNodeInContentsMatcher = any => number; |
There was a problem hiding this comment.
perhaps this should be
type NodeMatcher = Node => numbershorter and clearer naming, and we can get the node from the types (it is already imported)
src/utils/sources-tree/addToTree.js
Outdated
| } | ||
|
|
||
| /* | ||
| * Creates a matcher for findNodeInContents. |
There was a problem hiding this comment.
you are returning a ternary result, -1, 0 or 1. However it is unclear given how the code is written
instead, set constants for this:
// `T` in this case stands for ternary. These are values associated with Ternary logic: https://en.wikipedia.org/wiki/Three-valued_logic
const T_FALSE = -1;
const T_UNKNOWN = 0;
const T_TRUE = 1;It is ugly but clear
There was a problem hiding this comment.
Actually, it's similar to what any comparison function will return: negative for less, 0 for equial and positive for greater
src/utils/sources-tree/addToTree.js
Outdated
| } else if (!nodeIsDir && isDir) { | ||
| return 1; | ||
| } | ||
| return node.name.localeCompare(part); |
There was a problem hiding this comment.
this should be consistent with the rest
return node.name.localeCompare(part) ? 1 : 0; // but using either T_TRUE or T_UNKNOWNThere was a problem hiding this comment.
Added comments to the FindNodeInContentsMatcher instead.
src/utils/sources-tree/addToTree.js
Outdated
| * The matcher is a function that returns result of comparision of a node with | ||
| * lookup value. | ||
| */ | ||
| function findNodeInContents(tree: Node, matcher: FindNodeInContentsMatcher) { |
There was a problem hiding this comment.
describing this function in plain english, and using the ternary values I defined elsewhere (T_TRUE = 1, T_UNKNOWN = 0, T_FALSE = -1):
-
we take the tree contents which is an array. if that array is empty, we return -1.
-
if it is not empty, we set a start point ('l' for left) and an end point ('r' for right)
-
so long as the starting point is less than the end point, we also select a center point ('c')
-
if the center point is
T_FALSE( -1 ) -- then it should be at the bottom of the list, so we set the start point (l) to c + 1 -
otherwise, the center point is
T_UNKNOWN, orT_TRUE, so we set the ending point to C
example:
0|1|2|3|4
----------
l| |c| |r
if (matcher(contents[c]) === `T_FALSE`)
0|1|2|3|4
----------
| | |l, c|r // ignore the first half of the array
else
0|1|2|3|4
----------
l|c|r| | // ignore the second half of the array
- Once the loop completes, (and our starting point "l" is greater than our endpoint "r")
0|1|2|3|4
----------
|r|l| |
0|1|2|3|4
----------
| | | |r|l // outside of the original array if all matcher checks return `T_FALSE`
we check if the result is T_UNKNOWN. If it is unknown, we return the starting value ("l").
If it is either T_FALSE (-1) or T_TRUE (1), then
- check if it is
T_FALSE, if it is, return the starting point ('l'). - if it is
T_TRUE, return the starting point ('l') plus 1.
whatever the result is, make it negative and -1 from it.
0|1|2|3|4
----------
|r|l|x| // if `T_FALSE` is true, the returned position will be -(l + 1) ( also see above for the off by one case, where | | | |r|l|x -- is outside of the existing array by two spots)
0|1|2|3|4
----------
|r|l| |x| // if `T_TRUE` is true, the returned position will be -(l + 2)
this code is essentially taking an array, seeing if the matching position would be above or below the center, and halving it to the side where the element might be found. That isnt immediately clear from the code. there are two things contributing to this:
- bad naming. Single character variable names shouldn't be used except in special situations, and this isn't one of them.
- return value is doing too much. it is unclear to me why we need it to be negative, or why we need to add +1 to it. can you clarify why this is happening? also, there are a lot of magic things happening, for example +1 is being added in a number of places without any reason explained behind it. return value is a good example of "why are we adding 1 and then making the whole thing negative and then adding 1 to it again". at the very least the return value needs to be split up
it also seems like we are avoiding complex data structures, but in this case i think we need them. we shouldnt be checking for negative indexs to tell if a node is new or not.
There was a problem hiding this comment.
Sorry, I don't follow your analysis. The algorithm above is basic binary search algorithm. I renamed 'l' and 'r' to 'left' and 'right' for clarity.
There was a problem hiding this comment.
describing this function in plain english, and using the ternary values I defined elsewhere
The algorithm is using return values similar to comparefn defined in http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.11 , and these are not compatible with ternary values.
There was a problem hiding this comment.
👍 i mean ternary as in: https://en.wikipedia.org/wiki/Three-valued_logic -- which i see as being similar to what is going on in the sort / comparefn that you linked (the difference being that 0 is used for "equal" instead of "undefined"). But i could be wrong... anyway, thank you for the changes it reads much better!
There was a problem hiding this comment.
there is no guarantee that localeCompare() will return only -1, 0, or 1 (based on spec). Writing const result = name1.localeCompare(name2); return result === 0 ? T_UNKNOWN : result < 0 ? T_FALSE : T_TRUE; to accommodate ternary values does not make any sense (and unreadable) IMHO.
src/utils/sources-tree/addToTree.js
Outdated
| * - hosts/directories (not files) sorted by name | ||
| * - files sorted by name | ||
| */ | ||
| function createTreeNodeMatcher( |
There was a problem hiding this comment.
this should be moved to its own file, each HOF can be split into its own function and named. that way you wont have to add so many comments
function indexMatcher(indexName) {
return (node) => (node.name === IndexName ? 0 : 1);
}
function domainMatcher(indexName, debuggeeHost) {
return node => {
if (node.name === IndexName) {
return -1;
}
return isExactDomainMatch(node.name, (debuggeeHost: any)) ? 0 : 1;
};
}
createTreeNodeMatcher(...) {
//...
if (part === IndexName) {
return IndexMatcher(indexName)
}
if (debuggeeHost && isExactDomainMatch(part, debuggeeHost)) {
return domainMatcher(indexName, debuggeeHost)
}
// ... etcThere was a problem hiding this comment.
Code was moved to the ./treeOrder.js file.
src/utils/sources-tree/addToTree.js
Outdated
| /* | ||
| * Performs a binary search to insert a node into contents. Returns positive | ||
| * number, index of the found child, or negative number, which can be used | ||
| * to calculate a position where a new node can be inserted (`-index - 1`). |
There was a problem hiding this comment.
so, if an index is negative, it is a new node? and if it is positive it is an existing node? that is difficult to understand. why not use a tuple? { index: , newNode: }
| return createNodeInTree(part, path, subTree); | ||
| if (childIndex < 0) { | ||
| return createNodeInTree(part, path, subTree, -childIndex - 1); | ||
| } |
| return [...node.contents, newNode]; | ||
| const contents = node.contents.slice(0); | ||
| contents.splice(-childIndex - 1, 0, newNode); | ||
| return contents; |
There was a problem hiding this comment.
it is so unclear what is going on here. we shouldn't be using negative numbers to determine if something is a new node
There was a problem hiding this comment.
Changed return type to return an object (I hope JIT will not create lots of objects in memory to GC them later). Measured performance for 3k file -- there was no real change in the performance.
8d0057a to
2b2b31f
Compare
2b2b31f to
d125c40
Compare
| if (result === 0) { | ||
| return { found: true, index: left }; | ||
| } | ||
| return { found: false, index: result > 0 ? left : left + 1 }; |
There was a problem hiding this comment.
thanks for clarifying why you were doing what you were doing before! The garbage collection might be an issue, true. I hadn't thought of that, and you are totally right
Perhaps a way to make the code readable and more memory efficient (trying to balance things 😅), we could keep the code you had (with a comment about what it was doing, a more explicit comment)
then where the value is used, have a wrapper function that translates the value?
ie)
export function findNodeInContents(
// ...
// returns a negative value for a new node, offset by one
// returns a positive value for an existing node
return -(result > 0 ? left : left + 1 ) - 1;with helpers
function childFound(child) {
return child > -1
}
function determineIndex(child) {
// return a valid index whether the child is new (an therefore a negative number off by one)
// or if the child is an existing index
return child > -1 ? child : -child - 1;
}then where it is used:
if (!childFound(childIndex)) {
return createNodeInTree(part, path, subTree, determineIndex(childIndex));
}There was a problem hiding this comment.
I would keep that as is for now for readability. We can re-open the issue later. It's hard to measure atm -- it's impossible to run it with 10,000 or 30,000 load.
|
Thanks for the clarifications yury! i made one more comment for your feedback |
|
awesome work! |
update feature flags Preview: Show numbers inside a tooltip (firefox-devtools#4164) bump mochii Update devtools package Preview: Show numbers inside a tooltip fix the failing pending breakpoints tests (firefox-devtools#4175) Switch Scopes form PropTypes to Flow Props (firefox-devtools#4180) No domain (firefox-devtools#4159) Adding "Add condition" to breakpoints context menu (firefox-devtools#4157) Don't show "No sources" hint if sources panel is hidden (firefox-devtools#4179) * Don't show "No sources" hint if sources panel is hidden * Don't hide PrimaryPane components via css * fix linting error * remove unused import Cleanup addbreakpoints (firefox-devtools#4184) Show mapped names in scopes bindings (firefox-devtools#3817) Flow types (firefox-devtools#4197) * Fix flow error Footer * Fix flow error Breakpint, Breakpoints Fix breakpoint jumping (firefox-devtools#4191) Validate expression syntax (firefox-devtools#4114) * validate expressions * add missing test * bump mochii Fix ESLint Dependencies from Fresh Install (firefox-devtools#4178) * Add dependencies for linting * Fix linting errors in master * Fix package.json lint errors Fix firefox-devtools#4043 - Change localization note and errorLoadingText (firefox-devtools#4058) Fix linting warnings (firefox-devtools#4204) Small style improvements on breakpoint and watch expression (firefox-devtools#4057) * PR#4057 - PART1: [breakpoint] small style improvements * PR#4057 - PART2: [watch expression] small style improvements 9-27 update (firefox-devtools#4193) Shortcuts style tweak (firefox-devtools#4202) Scroll bar is not ignored in vertical mode calculations (firefox-devtools#4127) Bump react to 15.6.2 (firefox-devtools#4160) Upgrade tree component (firefox-devtools#4215) Revert "Upgrade tree component (firefox-devtools#4215)" (firefox-devtools#4224) This reverts commit 179582c. Switch Popover PropTypes to flow props (firefox-devtools#4227) Fix source tabs not lining up with file tabs (firefox-devtools#4139) memoize loading (firefox-devtools#4216) Issue firefox-devtools#3966: Show small values inside tooltip (firefox-devtools#4218) add line about vulnerabilities (firefox-devtools#4231) Fix responsive issue on WelcomeBox (firefox-devtools#4119) remove paused class (firefox-devtools#4235) Fix webpack icon matching (firefox-devtools#4240) bump 9-29 (firefox-devtools#4214) * bump 9-29 * Revert "Upgrade tree component (firefox-devtools#4215)" This reverts commit 179582c. * assets Update devtools-source-map to the latest version 🚀 (firefox-devtools#4222) * fix(package): update devtools-source-map to version 0.14.2 * fix update script * bump yarn Fix some lingering POE + Exception bugs (firefox-devtools#4225) firefox doesn't like fit-content (firefox-devtools#4219) Disables updateScopeBindings for wasm source maps. (firefox-devtools#4245) React preview (firefox-devtools#4228) Moved workers to their own Worker directory. (firefox-devtools#4230) Show the full url of a file in the source tab tooltip (firefox-devtools#4203) (firefox-devtools#4226) Fixed Webpack Alignment (firefox-devtools#4250) AST Test (firefox-devtools#4249) remove unnecessary line Fix 4246 - Prevent validateDOMNesting warning (firefox-devtools#4247) remove mocha (firefox-devtools#4254) Claim an issue (firefox-devtools#4255) Fix some react test warnings (firefox-devtools#4248) Adds readme with debugger.html version information to mc. Fix prop-type warnings (firefox-devtools#4257) * Add separate prop-types dependency Using prop types from the React repo has been deprecated. * Alphabetize dependencies and remove duplicates Remove usage of create factory (firefox-devtools#4260) Lint equality (firefox-devtools#4278) * Updated text after equality linting * clean up Migrate ManagedTree proptypes to flow (firefox-devtools#4272) Add Command Slash Shortcut (firefox-devtools#4265) Closes firefox-devtools#4213 Stop breakpoint label click from toggling breakpoint (firefox-devtools#4269) Addresses firefox-devtools#4262 Provides the primary purpose of linking to the breakpoint's location in source. Extract temp variables for wrapped components in their tests (firefox-devtools#4279) [firefox-devtools#4270] Add tests for DevToolsUtils (firefox-devtools#4271) Optimize addToTree function. (firefox-devtools#4263) Fix one case of different lodash import format (firefox-devtools#4289) Make keyboard shortcuts button more specific and localized (firefox-devtools#4293) Fixing source-documents linting error (firefox-devtools#4290) Fix 4261 - Sort breakpoints by line number (firefox-devtools#4264) * Fix 4261 - Sort breakpoints by line number * Fix flow issues * Use lodash's sortBy for breakpoint sorting Remove object.assign from selectors.js close firefox-devtools#4267 (firefox-devtools#4268) Removes unneeded SVG DOM elements for source tree arrows. (firefox-devtools#4283) Added step over functionality for yield (firefox-devtools#4232) (firefox-devtools#4276) * Added step over functionality for yield (firefox-devtools#4232) * Consistent parser steps naming and generators fixture Proposal for closing firefox-devtools#3172 (firefox-devtools#4266) Updating docs (firefox-devtools#4298) Support framework frames for Preact (firefox-devtools#4296) Attempt to reduce intermittent failures for wasm-sourcemaps test. (firefox-devtools#4305) Fix Source Tree padding left (firefox-devtools#4303) * Fix Source Tree padding left * change to match the top ooutline spacing Change component function binding to class properties (firefox-devtools#4302) show mapped names in watch expressions (firefox-devtools#4206) - unifies right click "Copy source URI" for tree view & tab view (firefox-devtools#4325) bump lock file (firefox-devtools#4317) Release (10/6) (firefox-devtools#4322) Protect Worker and Browser Content Toolboxes (firefox-devtools#4331) Use Flow for Proptype checking in Source Tree Fix flow error (wip) Show class functions in the outline! (firefox-devtools#4286) WIP - Fix Secondary Panes Scroll Bar (firefox-devtools#4275) Simplify Editor LifeCycle (firefox-devtools#4301) Align empty message in Source Tab (firefox-devtools#4337) Remove last vestige of devtools.debugger.client-source-maps-enabled (firefox-devtools#4339) Fixed issue firefox-devtools#4291 (firefox-devtools#4340) Update travis MC commit (firefox-devtools#4335) Make alt click expand/collapse all the nodes cleanup ... Debugger Release (firefox-devtools#4341) Replace lodash find with native Array::find. Fixes firefox-devtools#4343. (firefox-devtools#4344) add a GotoLineModal (firefox-devtools#4323) This commit adds a gotoline modal/functionality triggered with `Cmd+:` (`CtrlOrCmd+Shift+;`) in the main debugger source window. A string that cannot be `parseInt()`'d is a noop. A number higher than the number of lines in the file will go to the end of the file. Upgrade Launchpad (firefox-devtools#4332) Improve maintainer experience (firefox-devtools#4352) Update sources arrow (firefox-devtools#4351) fix browser toolbox issues (firefox-devtools#4347) add getDomain tst (firefox-devtools#4356) Tidies up reducer comments (firefox-devtools#4354) modal height and position changed (firefox-devtools#4277) travis bump (firefox-devtools#4358) Improve triaging docs (firefox-devtools#4321) Attempt to address "Debugger.Frame is not live". [SourceTree] Set root directory (firefox-devtools#4363) * Preview: Show numbers inside a tooltip (firefox-devtools#4164) * initial commit * resolved conflicts in src/actions/ui.js and updated debugger.properties and SourcesTree.js based on flodolo and jasonLaster feedback * Update debugger.properties fix key remove svgs Update Module Manifest Update Module Manifest Update Module Manifest Update Module Manifest Update Module Manifest Update Module Manifest Update Release (3) Update Release (3) Removed tabs + button (firefox-devtools#4367) * Removed tabs + button Issue firefox-devtools#4312 Removed: - import of formatKeyShortcut - onclick - render newButton method Kept: SVG plus icon L10N "sourceTabs.newTabButtonTooltip" key value pair * Removed tabs + button Issue firefox-devtools#4312 Removed: - import of formatKeyShortcut - onclick - render newButton method - debugger.properties sourceTabs.newTabButtonTooltip Kept: SVG plus icon add docs on merge conflicts (firefox-devtools#4365) File search reducer (firefox-devtools#4368) Fixes mis-aligned tooltip (firefox-devtools#4370) * Fixes mis-aligned tooltip * tweaks Fix Empty Lines off by one issue (firefox-devtools#4361) get display name and pass it to Popup.js (firefox-devtools#4357) small prettier changes (firefox-devtools#4364) Adds L10N for previously hardcoded keybindings (firefox-devtools#4378) * Adds L10N for previously hardcoded keybindings * Updates keybindings as requested by owner Update Release (10-13) (firefox-devtools#4380) add shortcuts modal in vertical mode (firefox-devtools#4288) (firefox-devtools#4375) Update Shortcuts button (firefox-devtools#4382) docs most-common-issues (firefox-devtools#4295) Use a monospace font for editor line numbers (firefox-devtools#4391) Set layout change Cleanup babel (firefox-devtools#4404) Adds flow types to the Scope declaration. (firefox-devtools#4405) Synchronize smoke test for browser content toolbox from m-c (firefox-devtools#4408) Update mochii to the latest version 🚀 (firefox-devtools#4414) Converted blackBox/prettyPrint SVG's to CSS (firefox-devtools#4386) Revert "Use a monospace font for editor line numbers" (firefox-devtools#4416) This reverts commit 2544fc1. Fix "3" expressions Fix firefox-devtools#4397 - Don't allow context menu when a line is empty 🔨: Rework `SourceSearch` into `SourcesModal` (firefox-devtools#4398) Keeps focus on input field (firefox-devtools#4423) add layout test (firefox-devtools#4415) Change port 9000 default to 8116 default (firefox-devtools#4434) Scroll to column (firefox-devtools#4143) * fix issue with the line not highlighting in the editor * undo some changes to test * fix * switch to watForLoaded * flash line all ways * fix the conditional breakpoint panel mochitest * if there is no selected location bail early, fix a mochitest * fix mochitests, cleanup index * fix the dbg-tabs mochitest * fix the breakpoint visible mochitest issue * fix the failing unit tests * stop nesting the location info * more cleanups Upgrade flow (firefox-devtools#4433) * Upgrade Flow * Use `static` properties for `defaultProps` Flow uses the defaultProps static property to type the default props. * Convert a set of components over to the new Flow syntax * Remove a usage of 'createFactory' * Convert another batch of components over to the new Flow syntax * Convert yet another batch of components over to the new Flow syntax * Remove unused file This file was originally removed in 6ba9b0b. However, while merging in master in e60cedd, I accidentally added the file back. * Don't type check devtools-reps * Update ref for the ConditionalPanel Per the Flow docs (https://flow.org/en/docs/react/refs/), we need to explicitly set the type of the ref and ensure that it is nullable. * Convert more files to the new Flow syntax * Update the last items for the new Flow syntax * Only ignore the object-inspector So that we can still import its types. * Change flow types to use primitive values Support framework frames for Marko (firefox-devtools#4430) * added marko to library frames * code simplified * refactoring library map * moving great before react fix bug where the line being 0 returns a falsy (firefox-devtools#4445) * fix bug where the line being 0 returns a falsy and does not cause the line to flash * use isLoaded util update 10-17-2017 (firefox-devtools#4400) * update 10-17-2017 * update according to jlast's comments * fix lint bump yarn (firefox-devtools#4442) Undo string change to editor.addConditionalBreakpoint (firefox-devtools#4448) Working class and imports finder (firefox-devtools#4329) 10/13 2nd release (firefox-devtools#4447) support framework frames for aframe (firefox-devtools#4458) Fix warnings for var usage (firefox-devtools#4456) bump launchpad (firefox-devtools#4452) add support framework frames for Nuxt.js (firefox-devtools#2980) (firefox-devtools#4460) Add Jest Cases Fix links in debugging-the-debugger page Fix links in getting-setup page Fix links in getting-setup page 1 Blackboxed sources distinguished by icon in source tree (firefox-devtools#4441) Fixes 3846 Source Tabs and Gutter Column Don't Line Up (firefox-devtools#4427) * Update PaneToggle.css * Update Tabs.css * fix for dynamic width * error check for no element * moving ui related utilities to utils/ui file * adding export to each function Update README.md fix firefox-devtools#4471 - expand the right sidebar on pausing at breakpoint event stopped for context menu for non firefox browsers event prevent default moved Add next.js to framework frames (firefox-devtools#4476) Converted Source Tree SVG's (including Blackbox) to images using CSS styles (firefox-devtools#4350) (firefox-devtools#4477) add the computed property to allow differentiating between computed and uncomputed memberexpressions fix flow move the func to a utility file added tests fix tests Fix footer background length in dark theme Highlight errors in editor fix css linting errors cleanup Make error background color lighter refactoring fix getting the lineNo from CoideMirror (firefox-devtools#4466) Move workflow to pr docs (wip) Refactor pause actions (firefox-devtools#4439) * Update Pause Semantics [Issue-4486]-Changing the overflow rule of secondaryPanel to pr… (firefox-devtools#4487) QuickOpenModal (firefox-devtools#4464) Fix cross-configuration problems (firefox-devtools#4475) * Add gitattributes * fix: Multi-platform and configuration issues This configures all systems to checkout and use LF line endings. The jest test system also runs without colors by default now. This allows the tests to pass in any environment regardless of color scheme. * tweaks bump mochi Close ConditionalPanel on blur [Preview] Some lines are incorrectly marked as out of scope Add travis notifications 🐛: Fix the quick-open mochitest There were some race issues with the quick open mochitest assertions that this cleared up. 📝: Add some mochitest debugging tips. Added some tips to the mochitest debugging docs based on experience debugging race issue. Also Prettier fixed some things. tweaks Weekly Post - 10-24 (firefox-devtools#4494) Remove createClass and Proptypes warning (firefox-devtools#4510) (firefox-devtools#4350) Converted Step Button SVG's to images using CSS Styles (firefox-devtools#4502) notify on failure (firefox-devtools#4511) Fixes firefox-devtools#4505 - Convert file SVG to image (firefox-devtools#4514) add terminology (firefox-devtools#4512) * add terminology * Update terminology.md fix l10n label (firefox-devtools#4518) Fix parser returning failing to clone data (firefox-devtools#4520) debugging firefox add a use-case for feature flags Update local-development.md Unselects highlight on search window close Updates tests Fixing Shortcut Modal Dark Theme Legibility on Mac Move selected PrimaryTab local state to redux Fix typo another typo Cleanup Move selected PrimaryTab local state to redux 🐛: Use onKeyDown in SearchBar to allow for simpler iteration of results (firefox-devtools#4533) In the QuickOpenModal we found that using onKeyDown meant a user could hold up/down to traverse their results more easily. In the searchbar holding enter does the same. Closes firefox-devtools#2527 removes declared hooks on componentWillUnmount (firefox-devtools#4426) * removes declared hooks on componentWillUnmount * changes listener binding from fat arrow to bind(this) Style debuggee domain (firefox-devtools#4536) 🎨: Update our symbol parsing code to extract additional function types (firefox-devtools#4531) Remove query strings when displaying call stack frames (firefox-devtools#4535) [firefox-devtools#4545] Add tests for src/utils/assert.js (firefox-devtools#4546) Fix filename for assert.js tests Add tests for src/utils/log.js Displays result count only after initiating search (firefox-devtools#4525) Use new redux action in editor (firefox-devtools#4552) Refactor waitForPaused colon removed from subtitle CI fix show better error messages in jest (firefox-devtools#4558) Add timing data (firefox-devtools#4540) Refactor command action to use PROMISE (firefox-devtools#4554) * Refactor waitForPaused * Refactor command to be async Release 10/25 (firefox-devtools#4493) 10-31 (firefox-devtools#4543) updates readme 10/31 Update mochii to the latest version 🚀 (firefox-devtools#4562) Refactor map scopes to fetch scopes (firefox-devtools#4550) bump map-bindings (firefox-devtools#4566) togglePaneCollapse update (firefox-devtools#4508) Validate scripts (firefox-devtools#4565) do not expand all scope objects (firefox-devtools#4498) Update mochii to the latest version 🚀 (firefox-devtools#4576) Fix conditional breakpoints (firefox-devtools#4465) Update github-airtable-bridge to the latest version 🚀 (firefox-devtools#4578) Dont show Mochi output for passing tests (firefox-devtools#4580) Add airtable crm config (firefox-devtools#4582) Add Unit Tests for Editor (firefox-devtools#4522) Moves redux middleware to actions/utils (firefox-devtools#4567) * Moves redux middleware to actions/utils * Fixes import path in Jest * Changes directory from actions/utils to actions/utils/middleware * moves create-store from utils/middleware to utils Fix jest intermittent - quick open FIX - cmd+shift+b is no longer bound (firefox-devtools#4595) * cmd+shift+b is no longer bound - Fix * Fix2 - cmd+shift+b is no longer bound * action fix - cmd+shift+b is no longer bound Re-enable tests (firefox-devtools#4564) Improve JSX syntax highlighting (firefox-devtools#4539) Mochi intermittent script (firefox-devtools#4586) Disallow uncaught exceptions (firefox-devtools#4584) Optimistically clear pause state (firefox-devtools#4557) Competing Scripts - break webpack (firefox-devtools#4606) * Competing Scripts - break webpack * Update most-common-issues.md Fixes secondary pane css classes being localized (firefox-devtools#4611) Preview mochitest (firefox-devtools#4603) Panel fixes (firefox-devtools#4598) Add some additional helper methods Exclude flow types from identifier locations Add a license header (firefox-devtools#4601) Fix display of return value / thrown exception in scopes (firefox-devtools#4569) Adds mk_add_options AUTOCLOBBER=1 to .mozconfig (firefox-devtools#4622) Add launchpad screenshot (firefox-devtools#4623) bump bindings (firefox-devtools#4625) fix markdown lint (firefox-devtools#4626) Upgrade flow (firefox-devtools#4591) spell check docs (firefox-devtools#4627) Fix flow ignore (firefox-devtools#4628) flash function when it is copied - feature firefox-devtools#4022 (firefox-devtools#4634) added flash action Update mochii to the latest version 🚀 (firefox-devtools#4638) Issue ADD_SCOPES even for wasm files. (firefox-devtools#4637) Issue firefox-devtools#4639 - bump devtools-reps to 0.12.4 Issue firefox-devtools#4639 - update yarn.lock Replaces Object.assign with ... spread (firefox-devtools#4574) Re-enable wasm test (firefox-devtools#4644) Release the debugger (firefox-devtools#4633) * Bug 4420 fix * tweaks Add small lint fixes
bump mochii Update devtools package Preview: Show numbers inside a tooltip fix the failing pending breakpoints tests (firefox-devtools#4175) Switch Scopes form PropTypes to Flow Props (firefox-devtools#4180) No domain (firefox-devtools#4159) Adding "Add condition" to breakpoints context menu (firefox-devtools#4157) Don't show "No sources" hint if sources panel is hidden (firefox-devtools#4179) * Don't show "No sources" hint if sources panel is hidden * Don't hide PrimaryPane components via css * fix linting error * remove unused import Cleanup addbreakpoints (firefox-devtools#4184) Show mapped names in scopes bindings (firefox-devtools#3817) Flow types (firefox-devtools#4197) * Fix flow error Footer * Fix flow error Breakpint, Breakpoints Fix breakpoint jumping (firefox-devtools#4191) Validate expression syntax (firefox-devtools#4114) * validate expressions * add missing test * bump mochii Fix ESLint Dependencies from Fresh Install (firefox-devtools#4178) * Add dependencies for linting * Fix linting errors in master * Fix package.json lint errors Fix firefox-devtools#4043 - Change localization note and errorLoadingText (firefox-devtools#4058) Fix linting warnings (firefox-devtools#4204) Small style improvements on breakpoint and watch expression (firefox-devtools#4057) * PR#4057 - PART1: [breakpoint] small style improvements * PR#4057 - PART2: [watch expression] small style improvements 9-27 update (firefox-devtools#4193) Shortcuts style tweak (firefox-devtools#4202) Scroll bar is not ignored in vertical mode calculations (firefox-devtools#4127) Bump react to 15.6.2 (firefox-devtools#4160) Upgrade tree component (firefox-devtools#4215) Revert "Upgrade tree component (firefox-devtools#4215)" (firefox-devtools#4224) This reverts commit 179582c. Switch Popover PropTypes to flow props (firefox-devtools#4227) Fix source tabs not lining up with file tabs (firefox-devtools#4139) memoize loading (firefox-devtools#4216) Issue firefox-devtools#3966: Show small values inside tooltip (firefox-devtools#4218) add line about vulnerabilities (firefox-devtools#4231) Fix responsive issue on WelcomeBox (firefox-devtools#4119) remove paused class (firefox-devtools#4235) Fix webpack icon matching (firefox-devtools#4240) bump 9-29 (firefox-devtools#4214) * bump 9-29 * Revert "Upgrade tree component (firefox-devtools#4215)" This reverts commit 179582c. * assets Update devtools-source-map to the latest version 🚀 (firefox-devtools#4222) * fix(package): update devtools-source-map to version 0.14.2 * fix update script * bump yarn Fix some lingering POE + Exception bugs (firefox-devtools#4225) firefox doesn't like fit-content (firefox-devtools#4219) Disables updateScopeBindings for wasm source maps. (firefox-devtools#4245) React preview (firefox-devtools#4228) Moved workers to their own Worker directory. (firefox-devtools#4230) Show the full url of a file in the source tab tooltip (firefox-devtools#4203) (firefox-devtools#4226) Fixed Webpack Alignment (firefox-devtools#4250) AST Test (firefox-devtools#4249) remove unnecessary line Fix 4246 - Prevent validateDOMNesting warning (firefox-devtools#4247) remove mocha (firefox-devtools#4254) Claim an issue (firefox-devtools#4255) Fix some react test warnings (firefox-devtools#4248) Adds readme with debugger.html version information to mc. Fix prop-type warnings (firefox-devtools#4257) * Add separate prop-types dependency Using prop types from the React repo has been deprecated. * Alphabetize dependencies and remove duplicates Remove usage of create factory (firefox-devtools#4260) Lint equality (firefox-devtools#4278) * Updated text after equality linting * clean up Migrate ManagedTree proptypes to flow (firefox-devtools#4272) Add Command Slash Shortcut (firefox-devtools#4265) Closes firefox-devtools#4213 Stop breakpoint label click from toggling breakpoint (firefox-devtools#4269) Addresses firefox-devtools#4262 Provides the primary purpose of linking to the breakpoint's location in source. Extract temp variables for wrapped components in their tests (firefox-devtools#4279) [firefox-devtools#4270] Add tests for DevToolsUtils (firefox-devtools#4271) Optimize addToTree function. (firefox-devtools#4263) Fix one case of different lodash import format (firefox-devtools#4289) Make keyboard shortcuts button more specific and localized (firefox-devtools#4293) Fixing source-documents linting error (firefox-devtools#4290) Fix 4261 - Sort breakpoints by line number (firefox-devtools#4264) * Fix 4261 - Sort breakpoints by line number * Fix flow issues * Use lodash's sortBy for breakpoint sorting Remove object.assign from selectors.js close firefox-devtools#4267 (firefox-devtools#4268) Removes unneeded SVG DOM elements for source tree arrows. (firefox-devtools#4283) Added step over functionality for yield (firefox-devtools#4232) (firefox-devtools#4276) * Added step over functionality for yield (firefox-devtools#4232) * Consistent parser steps naming and generators fixture Proposal for closing firefox-devtools#3172 (firefox-devtools#4266) Updating docs (firefox-devtools#4298) Support framework frames for Preact (firefox-devtools#4296) Attempt to reduce intermittent failures for wasm-sourcemaps test. (firefox-devtools#4305) Fix Source Tree padding left (firefox-devtools#4303) * Fix Source Tree padding left * change to match the top ooutline spacing Change component function binding to class properties (firefox-devtools#4302) show mapped names in watch expressions (firefox-devtools#4206) - unifies right click "Copy source URI" for tree view & tab view (firefox-devtools#4325) bump lock file (firefox-devtools#4317) Release (10/6) (firefox-devtools#4322) Protect Worker and Browser Content Toolboxes (firefox-devtools#4331) Use Flow for Proptype checking in Source Tree Fix flow error (wip) Show class functions in the outline! (firefox-devtools#4286) WIP - Fix Secondary Panes Scroll Bar (firefox-devtools#4275) Simplify Editor LifeCycle (firefox-devtools#4301) Align empty message in Source Tab (firefox-devtools#4337) Remove last vestige of devtools.debugger.client-source-maps-enabled (firefox-devtools#4339) Fixed issue firefox-devtools#4291 (firefox-devtools#4340) Update travis MC commit (firefox-devtools#4335) Make alt click expand/collapse all the nodes cleanup ... Debugger Release (firefox-devtools#4341) Replace lodash find with native Array::find. Fixes firefox-devtools#4343. (firefox-devtools#4344) add a GotoLineModal (firefox-devtools#4323) This commit adds a gotoline modal/functionality triggered with `Cmd+:` (`CtrlOrCmd+Shift+;`) in the main debugger source window. A string that cannot be `parseInt()`'d is a noop. A number higher than the number of lines in the file will go to the end of the file. Upgrade Launchpad (firefox-devtools#4332) Improve maintainer experience (firefox-devtools#4352) Update sources arrow (firefox-devtools#4351) fix browser toolbox issues (firefox-devtools#4347) add getDomain tst (firefox-devtools#4356) Tidies up reducer comments (firefox-devtools#4354) modal height and position changed (firefox-devtools#4277) travis bump (firefox-devtools#4358) Improve triaging docs (firefox-devtools#4321) Attempt to address "Debugger.Frame is not live". [SourceTree] Set root directory (firefox-devtools#4363) * Preview: Show numbers inside a tooltip (firefox-devtools#4164) * initial commit * resolved conflicts in src/actions/ui.js and updated debugger.properties and SourcesTree.js based on flodolo and jasonLaster feedback * Update debugger.properties fix key remove svgs Update Module Manifest Update Module Manifest Update Module Manifest Update Module Manifest Update Module Manifest Update Module Manifest Update Release (3) Update Release (3) Removed tabs + button (firefox-devtools#4367) * Removed tabs + button Issue firefox-devtools#4312 Removed: - import of formatKeyShortcut - onclick - render newButton method Kept: SVG plus icon L10N "sourceTabs.newTabButtonTooltip" key value pair * Removed tabs + button Issue firefox-devtools#4312 Removed: - import of formatKeyShortcut - onclick - render newButton method - debugger.properties sourceTabs.newTabButtonTooltip Kept: SVG plus icon add docs on merge conflicts (firefox-devtools#4365) File search reducer (firefox-devtools#4368) Fixes mis-aligned tooltip (firefox-devtools#4370) * Fixes mis-aligned tooltip * tweaks Fix Empty Lines off by one issue (firefox-devtools#4361) get display name and pass it to Popup.js (firefox-devtools#4357) small prettier changes (firefox-devtools#4364) Adds L10N for previously hardcoded keybindings (firefox-devtools#4378) * Adds L10N for previously hardcoded keybindings * Updates keybindings as requested by owner Update Release (10-13) (firefox-devtools#4380) add shortcuts modal in vertical mode (firefox-devtools#4288) (firefox-devtools#4375) Update Shortcuts button (firefox-devtools#4382) docs most-common-issues (firefox-devtools#4295) Use a monospace font for editor line numbers (firefox-devtools#4391) Set layout change Cleanup babel (firefox-devtools#4404) Adds flow types to the Scope declaration. (firefox-devtools#4405) Synchronize smoke test for browser content toolbox from m-c (firefox-devtools#4408) Update mochii to the latest version 🚀 (firefox-devtools#4414) Converted blackBox/prettyPrint SVG's to CSS (firefox-devtools#4386) Revert "Use a monospace font for editor line numbers" (firefox-devtools#4416) This reverts commit 2544fc1. Fix "3" expressions Fix firefox-devtools#4397 - Don't allow context menu when a line is empty 🔨: Rework `SourceSearch` into `SourcesModal` (firefox-devtools#4398) Keeps focus on input field (firefox-devtools#4423) add layout test (firefox-devtools#4415) Change port 9000 default to 8116 default (firefox-devtools#4434) Scroll to column (firefox-devtools#4143) * fix issue with the line not highlighting in the editor * undo some changes to test * fix * switch to watForLoaded * flash line all ways * fix the conditional breakpoint panel mochitest * if there is no selected location bail early, fix a mochitest * fix mochitests, cleanup index * fix the dbg-tabs mochitest * fix the breakpoint visible mochitest issue * fix the failing unit tests * stop nesting the location info * more cleanups Upgrade flow (firefox-devtools#4433) * Upgrade Flow * Use `static` properties for `defaultProps` Flow uses the defaultProps static property to type the default props. * Convert a set of components over to the new Flow syntax * Remove a usage of 'createFactory' * Convert another batch of components over to the new Flow syntax * Convert yet another batch of components over to the new Flow syntax * Remove unused file This file was originally removed in 6ba9b0b. However, while merging in master in e60cedd, I accidentally added the file back. * Don't type check devtools-reps * Update ref for the ConditionalPanel Per the Flow docs (https://flow.org/en/docs/react/refs/), we need to explicitly set the type of the ref and ensure that it is nullable. * Convert more files to the new Flow syntax * Update the last items for the new Flow syntax * Only ignore the object-inspector So that we can still import its types. * Change flow types to use primitive values Support framework frames for Marko (firefox-devtools#4430) * added marko to library frames * code simplified * refactoring library map * moving great before react fix bug where the line being 0 returns a falsy (firefox-devtools#4445) * fix bug where the line being 0 returns a falsy and does not cause the line to flash * use isLoaded util update 10-17-2017 (firefox-devtools#4400) * update 10-17-2017 * update according to jlast's comments * fix lint bump yarn (firefox-devtools#4442) Undo string change to editor.addConditionalBreakpoint (firefox-devtools#4448) Working class and imports finder (firefox-devtools#4329) 10/13 2nd release (firefox-devtools#4447) support framework frames for aframe (firefox-devtools#4458) Fix warnings for var usage (firefox-devtools#4456) bump launchpad (firefox-devtools#4452) add support framework frames for Nuxt.js (firefox-devtools#2980) (firefox-devtools#4460) Add Jest Cases Fix links in debugging-the-debugger page Fix links in getting-setup page Fix links in getting-setup page 1 Blackboxed sources distinguished by icon in source tree (firefox-devtools#4441) Fixes 3846 Source Tabs and Gutter Column Don't Line Up (firefox-devtools#4427) * Update PaneToggle.css * Update Tabs.css * fix for dynamic width * error check for no element * moving ui related utilities to utils/ui file * adding export to each function Update README.md fix firefox-devtools#4471 - expand the right sidebar on pausing at breakpoint event stopped for context menu for non firefox browsers event prevent default moved Add next.js to framework frames (firefox-devtools#4476) Converted Source Tree SVG's (including Blackbox) to images using CSS styles (firefox-devtools#4350) (firefox-devtools#4477) add the computed property to allow differentiating between computed and uncomputed memberexpressions fix flow move the func to a utility file added tests fix tests Fix footer background length in dark theme Highlight errors in editor fix css linting errors cleanup Make error background color lighter refactoring fix getting the lineNo from CoideMirror (firefox-devtools#4466) Move workflow to pr docs (wip) Refactor pause actions (firefox-devtools#4439) * Update Pause Semantics [Issue-4486]-Changing the overflow rule of secondaryPanel to pr… (firefox-devtools#4487) QuickOpenModal (firefox-devtools#4464) Fix cross-configuration problems (firefox-devtools#4475) * Add gitattributes * fix: Multi-platform and configuration issues This configures all systems to checkout and use LF line endings. The jest test system also runs without colors by default now. This allows the tests to pass in any environment regardless of color scheme. * tweaks bump mochi Close ConditionalPanel on blur [Preview] Some lines are incorrectly marked as out of scope Add travis notifications 🐛: Fix the quick-open mochitest There were some race issues with the quick open mochitest assertions that this cleared up. 📝: Add some mochitest debugging tips. Added some tips to the mochitest debugging docs based on experience debugging race issue. Also Prettier fixed some things. tweaks Weekly Post - 10-24 (firefox-devtools#4494) Remove createClass and Proptypes warning (firefox-devtools#4510) (firefox-devtools#4350) Converted Step Button SVG's to images using CSS Styles (firefox-devtools#4502) notify on failure (firefox-devtools#4511) Fixes firefox-devtools#4505 - Convert file SVG to image (firefox-devtools#4514) add terminology (firefox-devtools#4512) * add terminology * Update terminology.md fix l10n label (firefox-devtools#4518) Fix parser returning failing to clone data (firefox-devtools#4520) debugging firefox add a use-case for feature flags Update local-development.md Unselects highlight on search window close Updates tests Fixing Shortcut Modal Dark Theme Legibility on Mac Move selected PrimaryTab local state to redux Fix typo another typo Cleanup Move selected PrimaryTab local state to redux 🐛: Use onKeyDown in SearchBar to allow for simpler iteration of results (firefox-devtools#4533) In the QuickOpenModal we found that using onKeyDown meant a user could hold up/down to traverse their results more easily. In the searchbar holding enter does the same. Closes firefox-devtools#2527 removes declared hooks on componentWillUnmount (firefox-devtools#4426) * removes declared hooks on componentWillUnmount * changes listener binding from fat arrow to bind(this) Style debuggee domain (firefox-devtools#4536) 🎨: Update our symbol parsing code to extract additional function types (firefox-devtools#4531) Remove query strings when displaying call stack frames (firefox-devtools#4535) [firefox-devtools#4545] Add tests for src/utils/assert.js (firefox-devtools#4546) Fix filename for assert.js tests Add tests for src/utils/log.js Displays result count only after initiating search (firefox-devtools#4525) Use new redux action in editor (firefox-devtools#4552) Refactor waitForPaused colon removed from subtitle CI fix show better error messages in jest (firefox-devtools#4558) Add timing data (firefox-devtools#4540) Refactor command action to use PROMISE (firefox-devtools#4554) * Refactor waitForPaused * Refactor command to be async Release 10/25 (firefox-devtools#4493) 10-31 (firefox-devtools#4543) updates readme 10/31 Update mochii to the latest version 🚀 (firefox-devtools#4562) Refactor map scopes to fetch scopes (firefox-devtools#4550) bump map-bindings (firefox-devtools#4566) togglePaneCollapse update (firefox-devtools#4508) Validate scripts (firefox-devtools#4565) do not expand all scope objects (firefox-devtools#4498) Update mochii to the latest version 🚀 (firefox-devtools#4576) Fix conditional breakpoints (firefox-devtools#4465) Update github-airtable-bridge to the latest version 🚀 (firefox-devtools#4578) Dont show Mochi output for passing tests (firefox-devtools#4580) Add airtable crm config (firefox-devtools#4582) Add Unit Tests for Editor (firefox-devtools#4522) Moves redux middleware to actions/utils (firefox-devtools#4567) * Moves redux middleware to actions/utils * Fixes import path in Jest * Changes directory from actions/utils to actions/utils/middleware * moves create-store from utils/middleware to utils Fix jest intermittent - quick open FIX - cmd+shift+b is no longer bound (firefox-devtools#4595) * cmd+shift+b is no longer bound - Fix * Fix2 - cmd+shift+b is no longer bound * action fix - cmd+shift+b is no longer bound Re-enable tests (firefox-devtools#4564) Improve JSX syntax highlighting (firefox-devtools#4539) Mochi intermittent script (firefox-devtools#4586) Disallow uncaught exceptions (firefox-devtools#4584) Optimistically clear pause state (firefox-devtools#4557) Competing Scripts - break webpack (firefox-devtools#4606) * Competing Scripts - break webpack * Update most-common-issues.md Fixes secondary pane css classes being localized (firefox-devtools#4611) Preview mochitest (firefox-devtools#4603) Panel fixes (firefox-devtools#4598) Add some additional helper methods Exclude flow types from identifier locations Add a license header (firefox-devtools#4601) Fix display of return value / thrown exception in scopes (firefox-devtools#4569) Adds mk_add_options AUTOCLOBBER=1 to .mozconfig (firefox-devtools#4622) Add launchpad screenshot (firefox-devtools#4623) bump bindings (firefox-devtools#4625) fix markdown lint (firefox-devtools#4626) Upgrade flow (firefox-devtools#4591) spell check docs (firefox-devtools#4627) Fix flow ignore (firefox-devtools#4628) flash function when it is copied - feature firefox-devtools#4022 (firefox-devtools#4634) added flash action Update mochii to the latest version 🚀 (firefox-devtools#4638) Issue ADD_SCOPES even for wasm files. (firefox-devtools#4637) Issue firefox-devtools#4639 - bump devtools-reps to 0.12.4 Issue firefox-devtools#4639 - update yarn.lock Replaces Object.assign with ... spread (firefox-devtools#4574) Re-enable wasm test (firefox-devtools#4644) Release the debugger (firefox-devtools#4633) * Bug 4420 fix * tweaks Add small lint fixes Display more wast text lines (firefox-devtools#4648) Relax findSource Update mochitests.md Breakpoint setting unit tests (firefox-devtools#4655) * Breakpoint stepping unit tests * Working Tests Release (11-7) 2nd try (firefox-devtools#4670) * skip quick open on windows Drop react-immutable-proptypes (firefox-devtools#4667) Fix Console Hang Specify the ids of the jump and the add-watch-expression menuitems initial commit initial commit
Associated Issue: #4168
Summary of Changes
Test Plan
Added console.time() in the SourcesTree.js and createTree.js around addToTree+sortTree operations.
Measured performance of https://yurydelendik.github.io/old-man-sandbox/create-30k/f3k.html tree.
Before:

After:

Performance improved from 1186ms->291ms also affected subsequent/incremental tree update operations 180ms->2ms.