1#include "short_name.h"
2#include "base64.h"
3
4namespace taichi {
5namespace {
6const std::string alphatable =
7 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // e.g. `if` is not a good var name, but `If`
8 // does.
9const std::string alnumtable =
10 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
11}; // namespace
12
13std::string make_short_name_by_id(int id) {
14 std::string res;
15 while (id >= alphatable.size()) {
16 res.push_back(alnumtable[id % alnumtable.size()]);
17 id /= alnumtable.size();
18 }
19 res.push_back(alphatable[id]);
20 std::reverse(res.begin(), res.end());
21 return res;
22}
23} // namespace taichi
24