mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-13 01:36:15 +02:00
44c92a1667
there's a couple places that can be easily converted from using strings to using string_views instead. gives a slight (~1%) boost to system eval. # before nix eval --raw --impure --expr 'with import <nixpkgs/nixos> {}; system' Time (mean ± σ): 2.946 s ± 0.026 s [User: 2.655 s, System: 0.209 s] Range (min … max): 2.905 s … 2.995 s 20 runs # after Time (mean ± σ): 2.928 s ± 0.024 s [User: 2.638 s, System: 0.211 s] Range (min … max): 2.893 s … 2.970 s 20 runs
50 lines
870 B
C++
50 lines
870 B
C++
#pragma once
|
|
|
|
#include "ref.hh"
|
|
|
|
#include <list>
|
|
#include <set>
|
|
#include <string>
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
namespace nix {
|
|
|
|
using std::list;
|
|
using std::set;
|
|
using std::vector;
|
|
using std::string;
|
|
|
|
typedef list<string> Strings;
|
|
typedef set<string> StringSet;
|
|
typedef std::map<string, string> StringMap;
|
|
|
|
/* Paths are just strings. */
|
|
|
|
typedef string Path;
|
|
typedef std::string_view PathView;
|
|
typedef list<Path> Paths;
|
|
typedef set<Path> PathSet;
|
|
|
|
typedef vector<std::pair<string, string>> Headers;
|
|
|
|
/* Helper class to run code at startup. */
|
|
template<typename T>
|
|
struct OnStartup
|
|
{
|
|
OnStartup(T && t) { t(); }
|
|
};
|
|
|
|
/* Wrap bools to prevent string literals (i.e. 'char *') from being
|
|
cast to a bool in Attr. */
|
|
template<typename T>
|
|
struct Explicit {
|
|
T t;
|
|
|
|
bool operator ==(const Explicit<T> & other) const
|
|
{
|
|
return t == other.t;
|
|
}
|
|
};
|
|
|
|
}
|