mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 07:34:03 -06:00
Improved memory allocation efficiency of the 3D path preview generator.
This commit is contained in:
parent
1fb302d480
commit
3ebf0ce7fd
3 changed files with 59 additions and 41 deletions
|
@ -6,6 +6,33 @@ namespace Slic3r {
|
|||
extern void set_logging_level(unsigned int level);
|
||||
extern void trace(unsigned int level, const char *message);
|
||||
|
||||
// Compute the next highest power of 2 of 32-bit v
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html
|
||||
inline uint32_t next_highest_power_of_2(uint32_t v)
|
||||
{
|
||||
if (v != 0)
|
||||
-- v;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
return ++ v;
|
||||
}
|
||||
|
||||
inline uint64_t next_highest_power_of_2(uint64_t v)
|
||||
{
|
||||
if (v != 0)
|
||||
-- v;
|
||||
v |= v >> 1;
|
||||
v |= v >> 2;
|
||||
v |= v >> 4;
|
||||
v |= v >> 8;
|
||||
v |= v >> 16;
|
||||
v |= v >> 32;
|
||||
return ++ v;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_Utils_hpp_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue