You could use reduce(hcat,xx)'
(see How to convert Vector of Vectors to Matrix - #6 by rafael.guerra ), or in Julia 1.9 you can use stack
.
To improve speed further, you could maybe post a minimal working example so that people can run the code. (Not visible here, but just a guess: Make sure that you don’t use globals by accident.)
There might also be a way to write the code differently, like
function filter_triangles(triangles, tokeep)
counts = map(t -> tokeep[t[1]] + tokeep[t[2]] + tokeep[t[3]], triangles)
keep = counts .> 0
new_triangles = triangles[keep]
return (counts = counts[keep],
triangles = new_triangles,
connec = connect.(new_triangles))
end
(This uses more memory, but depending on your setting, it might even be faster.)
EDIT: As @fatteneder pointed out, I removed my wrong comment that Int
is an abstract type…