# Union splitting vs C++

**URL:** https://discourse.julialang.org/t/union-splitting-vs-c/61772
**Category:** Performance
**Created:** [May 25, 2021, 12:21pm UTC](https://discourse.julialang.org/t/union-splitting-vs-c/61772 "2021-05-25T12:21:49Z")
**Posts on this page:** 1
**Showing post:** 22

<div class="post-metadata">

### Author: ![melonedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/melonedo/32/15503_2.png) [@melonedo](https://discourse.julialang.org/u/melonedo)
#### Post date: [July 8, 2021, 3:54pm UTC](https://discourse.julialang.org/t/union-splitting-vs-c/61772/22 "2021-07-08T15:54:27Z")

</div>

Hello! I created an experimental package [SingleDispatchArrarys.jl](https://github.com/melonedo/SingleDispatchArrays.jl) that generates dispatch table for non-homogeneous arrays, which achieves c++ like performance for non-homogeneous arrays and is much more flexible to manage than manual switch-case.

However, c++ like performance is not necessary a good thing. With long if-elseif-elseif chain, LLVM generates jump table for this. On x86 machines, loading a jump table is nearly as fast as branching, but on Raspberry pi 4b, jump table is actually twice as slow as branching(20ms vs 10ms), looks like LLVM has made a bad choice.

---

_[View the full topic](https://discourse.julialang.org/t/union-splitting-vs-c/61772)._
