Skip to content

Commit

Permalink
Fix perf regressions
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuele Feliziani <[email protected]>
  • Loading branch information
GioSensation committed Sep 27, 2023
1 parent fa07388 commit ddc954d
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 75 deletions.
33 changes: 16 additions & 17 deletions dist/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 16 additions & 17 deletions dist/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions src/Form/FormAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ class FormAnalyzer {
shouldCheckUnifiedForm = false,
shouldBeConservative = false
}) {
// If the string is empty or too long (noisy) do nothing
if (
!string ||
string.length > constants.TEXT_LENGTH_CUTOFF
) return this

const matchesLogin = /current.?password/i.test(string) || this.matching.getDDGMatcherRegex('loginRegex')?.test(string) || this.matching.getDDGMatcherRegex('resetPasswordLink')?.test(string)

// Check explicitly for unified login/signup forms
Expand Down Expand Up @@ -177,9 +183,10 @@ class FormAnalyzer {
}

evaluatePageHeadings () {
const headings = document.querySelectorAll('h1, h2, h3, [class*="title"], [id*="title"]')
headings.forEach(({textContent}) => {
textContent = removeExcessWhitespace(textContent || '')
const headings = document.querySelectorAll('h1, h2, h3')
headings.forEach((heading) => {
const textContent = removeExcessWhitespace(heading.textContent || '')

this.updateSignal({
string: textContent,
strength: 0.5,
Expand Down Expand Up @@ -256,10 +263,7 @@ class FormAnalyzer {
this.updateSignal({string, strength, signalType: `external link: ${string}`, shouldFlip})
} else {
// any other case
// only consider the el if it's a small text to avoid noisy disclaimers
if (removeExcessWhitespace(el.textContent)?.length < constants.TEXT_LENGTH_CUTOFF) {
this.updateSignal({string, strength: 1, signalType: `generic: ${string}`, shouldCheckUnifiedForm: true})
}
this.updateSignal({string, strength: 1, signalType: `generic: ${string}`, shouldCheckUnifiedForm: true})
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/Scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ class DefaultScanner {
return
}

// Do not add explicitly search forms
if (parentForm.role === 'search') return

// Check if the forms we've seen are either disconnected,
// or are parent/child of the currently-found form
let previouslyFoundParent, childForm
Expand Down
33 changes: 16 additions & 17 deletions swift-package/Resources/assets/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 16 additions & 17 deletions swift-package/Resources/assets/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ddc954d

Please sign in to comment.