Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Stack alloc #207

Merged
merged 7 commits into from
Jun 21, 2017
Merged

Stack alloc #207

merged 7 commits into from
Jun 21, 2017

Conversation

Therzok
Copy link
Contributor

@Therzok Therzok commented Jun 17, 2017

No description provided.

int[] columns = new int[values.Length];
GLib.Value[] vals = new GLib.Value[values.Length];
int n_values = 0;
unsafe {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most important optimization, as we invoke this pretty often in MD.

@Therzok
Copy link
Contributor Author

Therzok commented Jun 19, 2017

60c3220

Means:
Faster allocation - not on the heap
No more GValueArray wrapper on the heap - plus, no more finalization for it.

@Therzok
Copy link
Contributor Author

Therzok commented Jun 19, 2017

Copy link
Member

@alanmcgovern alanmcgovern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Let's merge em after a day or two of local testing to make sure there aren't any oopses! It all looks fine to me though!

@alanmcgovern
Copy link
Member

Also one thing to keep in mind - there are no guarantees about the contents of stackalloced memory. It looks like we always fully initialize all memory we allocate this way, but if you ever want allocate an extra byte for a null terminator (or whatever) do remember to explicitly write null to that byte!

@Therzok
Copy link
Contributor Author

Therzok commented Jun 19, 2017

The stackallocs are mostly GLib.Value/Utf8String via marshal, so it's safe to assume we don't get uninitialized memory.

@alanmcgovern alanmcgovern merged commit 8c01ee1 into gtk-sharp-2-12-branch Jun 21, 2017
@alanmcgovern alanmcgovern deleted the stack-alloc branch June 21, 2017 13:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants