Closed Bug 1670547 Opened 1 year ago Closed 1 year ago

Make AutoArraySchemaWriter statically safer when not writing strings, remove unused code

Categories

(Core :: Gecko Profiler, task, P2)

task

Tracking

()

RESOLVED FIXED
83 Branch
Tracking Status
firefox83 --- fixed

People

(Reporter: gerald, Assigned: gerald)

References

Details

Attachments

(1 file)

AutoArraySchemaWriter::FreeFormElement() is never used, we can remove it.

When constructed, AutoArraySchemaWriter can optionally take a UniqueStrings reference, which is stored as a pointer.
Then AutoArraySchemaWriter::StringElement() does a MOZ_RELEASE_ASSERT(mStrings);.

We should split the class into two:

  • A writer that does not deal with strings at all, so we don't need a pointer to UniqueStrings.
  • A writer that can also deal with strings, in which we store a (non-null) UniqueStrings reference.

This is both:

  • Safer, because it's not possible to instantiate the non-string writer and try to write a string.
  • More efficient, because we don't need to pass&store a UniqueStrings reference/pointer when we don't deal with strings.

(Found while working on bug 1329600, in which it will be quite useful.)

AutoArraySchemaWriter::FreeFormElement() is never used, we can remove it.

When constructed, AutoArraySchemaWriter was optionally taking a UniqueStrings reference, which was stored as a pointer.
Then AutoArraySchemaWriter::StringElement() would do a dangerous MOZ_RELEASE_ASSERT(mStrings);.

The class is now split in two:

  • AutoArraySchemaWriter, which does not deal with strings at all, so we don't need a pointer to UniqueStrings.
  • AutoArraySchemaWithStringsWriter that can also deal with strings, in which we store a (non-null) UniqueStrings reference.

This is both:

  • Safer, because it's not possible to instantiate the non-string writer and try to write a string.
  • More efficient, because we don't need to pass&store a UniqueStrings reference/pointer when we don't deal with strings.
Pushed by gsquelart@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c19042d45111
Made AutoArraySchemaWriter safer and more efficient - r=canaltinova
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 83 Branch
You need to log in before you can comment on or make changes to this bug.