All Projects → dominikbraun → refreturn

dominikbraun / refreturn

Licence: other
Find functions that return a reference and cause allocations.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to refreturn

Lagmonitor
Monitor performance of your Minecraft server. Similar to VisualVM and Java Mission Control.
Stars: ✭ 147 (+444.44%)
Mutual labels:  heap
Ngraph.path
Path finding in a graph
Stars: ✭ 2,545 (+9325.93%)
Mutual labels:  heap
heap-js
Efficient Binary heap (priority queue, binary tree) data structure for JavaScript / TypeScript. Includes JavaScript methods, Python's heapq module methods, and Java's PriorityQueue methods.
Stars: ✭ 66 (+144.44%)
Mutual labels:  heap
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (+496.3%)
Mutual labels:  heap
C Macro Collections
Easy to use, header only, macro generated, generic and type-safe Data Structures in C
Stars: ✭ 192 (+611.11%)
Mutual labels:  heap
Data-Structure-Algorithm-Programs
This Repo consists of Data structures and Algorithms
Stars: ✭ 464 (+1618.52%)
Mutual labels:  heap
Isoalloc
A general purpose memory allocator that implements an isolation security strategy to mitigate memory safety issues while maintaining good performance
Stars: ✭ 130 (+381.48%)
Mutual labels:  heap
needle
📌📚 An extensive standalone data structure library for JavaScript.
Stars: ✭ 25 (-7.41%)
Mutual labels:  heap
Data Structures
A collection of powerful data structures
Stars: ✭ 2,534 (+9285.19%)
Mutual labels:  heap
DSA
Project : Data Structures and Algorithms in C#
Stars: ✭ 31 (+14.81%)
Mutual labels:  heap
Algo Tree
Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
Stars: ✭ 166 (+514.81%)
Mutual labels:  heap
Mysql Magic
dump mysql client password from memory
Stars: ✭ 183 (+577.78%)
Mutual labels:  heap
NALib
General purpose C sourcecode collection
Stars: ✭ 16 (-40.74%)
Mutual labels:  heap
Memoro
Memoro: A Detailed Heap Profiler
Stars: ✭ 159 (+488.89%)
Mutual labels:  heap
ctf-writeups
📚 Yet another CTF writeups repository. PWN and RE tasks
Stars: ✭ 29 (+7.41%)
Mutual labels:  heap
Binarytree
Python Library for Studying Binary Trees
Stars: ✭ 1,694 (+6174.07%)
Mutual labels:  heap
Fastpriorityqueue.js
a fast heap-based priority queue in JavaScript
Stars: ✭ 240 (+788.89%)
Mutual labels:  heap
cs.js
Computer Science Data Structures and Algorithms in JavaScript ( Node.JS, ES ) in simple, clean, reusable code
Stars: ✭ 86 (+218.52%)
Mutual labels:  heap
heaptrace
helps visualize heap operations for pwn and debugging
Stars: ✭ 252 (+833.33%)
Mutual labels:  heap
PixelGlitch
Image glitch visualization using various Pixel Sorting methods for Processing
Stars: ✭ 25 (-7.41%)
Mutual labels:  heap

refreturn

Find functions that return a reference and cause allocations.

When a function allocates a value and returns a reference to it, the value has to escape to the heap. This is slower and puts pressure on the garbage collector.

This may be optimized: You can avoid the heap allocation and allow the function to be inlined.


Example: a simple constructor

struct Coffee {
    Type string
}

func New() *Coffee {
    c := Coffee{
        Type: "espresso"
    }
    return &c
}
  1. Download refreturn and copy the binary into your project's root for example.
  2. Run ./refreturn <directory> and you'll see that New returns a reference.
  3. Check if the returned value is being created in the function.
  4. This is true for our c variable.
  5. Optimize the function like so:
func New() *Coffee {
    var c Coffee
    return new(&c)
}

func new(c *Coffee) *Coffee {
    c.Type = "espresso"
    return c
}

New() is now merely a wrapper which allocates the instance. The "real work" will be done in new().

This will allow mid-stack inlining as described in this blog post.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].