🖥️Hardware ArchitectureDEV CommunityContent type: Blog

Pointers and Tuning and Loops! Oh My! (opens in new tab)

Covers Compiler ExplorerDiscussed on DEV

Introduction While all code should be efficient, code for library-like components, especially involving loops, should be as efficient as possible since such code is often widely used. In my , I included the source code for a function to clean-up a dynamic array: void array_cleanup( array_t *array, array_free_fn_t free_fn ) { if ( array == NULL ) return; if ( free_fn != NULL ) { char *element = array->elements; for ( size_t i = 0; i len; ++i ) { (*free_fn)( element ); element += array...

Read the original article
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help