Last active
August 5, 2021 07:58
-
-
Save pervognsen/a002735fd626a481222e5204ac15b11e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For N = 11, a call to perms(p, N, 0) only takes 0.36 seconds. | |
// Why would a debugger seemingly hang forever when you try to | |
// step over the outermost recursive call to perms in the loop? | |
// Hint: How is "step over" ("next" in gdb/lldb) implemented? | |
u64 perms(u64 p[N], int n, u64 s) { | |
if (n == 1) { | |
s += signature(p); | |
} else { | |
for (int i = 0; i < n; i++) { | |
swap(p[0], p[i]); | |
s = perms(p + 1, n - 1, s); | |
swap(p[0], p[i]); | |
} | |
} | |
return s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've never bothered doing CFA but the strongest case for something like that is implementing efficient "step over" for inlined calls. I haven't thought it through in detail, though.