# How C++ Standard Library Implementations Optimize Zero-Filling

DevFeed: [How C++ Standard Library Implementations Optimize Zero-Filling](<https://devfeed.tech/articles/the-hunt-for-the-fastest-zero-28484.md>)

Original publisher: [Read original article](<https://travisdowns.github.io/blog/2020/01/20/zero.html>)

Author: Travis Downs (travis.downs@gmail.com)

Published: 2020-01-20T00:00:00Z

Content type: opinion

Language: en

Sources: [Performance Matters](<https://devfeed.tech/sources/performance-matters.md>)

Topics: [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Library](<https://devfeed.tech/topics/library.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [gcc](<https://devfeed.tech/topics/gcc.md>)

Tags: [blog](<https://devfeed.tech/tags/blog.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [compiler-optimization](<https://devfeed.tech/tags/compiler-optimization.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [library](<https://devfeed.tech/tags/library.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>)

## AI overview

This article examines why different C++ ways of filling an array with zeros can have substantially different performance. It explains that a standard-library implementation may recognize a special case and use a more efficient bulk operation, with the observed result depending on the compiler, optimization level, and hardware.

## Source excerpt

Unexpected performance deviations depending on how you spell zero.