# Speeding up a color transformation loop

**URL:** https://discourse.julialang.org/t/speeding-up-a-color-transformation-loop/106445
**Category:** Performance
**Created:** [November 19, 2023, 10:36pm UTC](https://discourse.julialang.org/t/speeding-up-a-color-transformation-loop/106445 "2023-11-19T22:36:24Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [November 20, 2023, 8:51am UTC](https://discourse.julialang.org/t/speeding-up-a-color-transformation-loop/106445/6 "2023-11-20T08:51:02Z")

</div>

> [@mpeters2](#):
>
> That’s just a snippet that is part of larger function.

If you want people to be able to help you well, you’ve got to give **self-contained examples** of whatever’s the problem. This means including an entire function, along with the data necessary to run it. See [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)

But don’t give us the huge function as in your actual code, rather you should produce a self-contained example that’s **representative** of your issue.

> [@mpeters2](#):
>
> not sure what you mean by h1, h2, and h3

Pretty sure they meant to deduplicate your code by assigning the common expressions to variables:

```julia
h1 = XYZlayers[1][xy]
h2 = XYZlayers[2][xy]
h3 = XYZlayers[3][xy]

```

If nothing else, that would make the code read better.

---

_[View the full topic](https://discourse.julialang.org/t/speeding-up-a-color-transformation-loop/106445)._
