Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • gjs gjs
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 104
    • Issues 104
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 21
    • Merge requests 21
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • gjsgjs
  • Merge requests
  • !504

Merged
Created Oct 01, 2020 by Marco Trevisan@3v1n0🎺Developer

Templated-data-only GjsAutoPointer (and use it more around)

  • Overview 26
  • Commits 17
  • Pipelines 8
  • Changes 17

I had this idea for some time, but given that this comment !494 (comment 908662) was enough to trigger me to actually do this...


We introduced GjsAutoPointer as part of commit dab3c7d0, to avoid duplication of the same code everywhere, and that served us well to create multiple smart pointer types, however since we were relying on std::unique_ptr, all the times we created a pointer with a custom destructor, we were allocating 8bits more, and this can be sensitive when used around in wrappers.

However, since we are already constructing the auto-pointers passing all these information as template (generating some custom code, for sure), we can just rely on the template parameters also for the destructor, and so ensuring that the struct size always matches the wrapped pointer, removing all the overhead.

This will allow to use GjsAutoPointer's everywhere without increasing the size of the wrapped objects.

As per this being all new (even though the API is mainly inspired to unique_ptr), adding various unit tests to ensure we behave correctly.


Also introduced real copy constructors (when we can) and FINALLY, real static checks on the function pointers that will ensure that we won't try to copy an object that has no ref_func set.

As per this, use it a bit more around given we won't include any extra overhead...

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: templated-gjs-autopointer