Skip to content

Instantly share code, notes, and snippets.

@zYeoman
Last active August 19, 2020 16:03
Show Gist options
  • Save zYeoman/01052aa948454c504ce148ec1876ac48 to your computer and use it in GitHub Desktop.
Save zYeoman/01052aa948454c504ce148ec1876ac48 to your computer and use it in GitHub Desktop.
snips

vector-inc

https://travisdowns.github.io/blog/2019/08/26/vector-inc.html 为什么vector<uint8_t>每个元素++比vector<uint32_t> 慢 (unsigned charchar 可变长)

void vector8_inc(std::vector<uint8_t>& v) {
    for (size_t i = 0; i < v.size(); i++) {
        v[i]++;
    }
}

void vector32_inc(std::vector<uint32_t>& v) {
    for (size_t i = 0; i < v.size(); i++) {
        v[i]++;
    }
}

// 这样的写法如何?
void vector8_inc(std::vector<uint8_t>& v) {
    for (size_t i = 0; i < const v.size(); i++) {
        v[i]++;
    }
}
strace 2>&1 <any_executable> |egrep -o "\".*\.conf\""
# from https://www.commandlinefu.com/commands/view/24983/list-all-accessed-configuration-files-while-executing-a-program-in-linux-terminal-improved-version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment