diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-08-22 18:53:55 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-09-07 10:52:31 -0700 |
commit | 61743aa190772a1c75acb75d274215274d0e6873 (patch) | |
tree | ca06c845c4ce20dd7ad1022c5bd28da8ff888cc0 /tests/headers/nsBaseHashtable.hpp | |
parent | 7346811ab5238feab406d6aee858197fa5254fcb (diff) |
Use `quote` instead of `syntex` for Rust code generation
The `syntex` crate is unmaintained. It is slow to build, and additionally it
requires that we pre-process `src/codegen/mod.rs` before we build the `bindgen`
crate.
The `quote` crate provides similar quasi-quoting functionality, is maintained,
and builds faster. It doesn't have a typed API or builders, however; it only
deals with tokens.
Before this commit:
```
$ cargo clean; cargo build
<snip>
Finished dev [unoptimized + debuginfo] target(s) in 98.75 secs
```
After this commit:
```
$ cargo clean; cargo build
<snip>
Finished dev [unoptimized + debuginfo] target(s) in 46.26 secs
```
Build time is cut in half! But what about run time?
Before this commit:
```
Generated Stylo bindings in: Duration { secs: 3, nanos: 521105668 }
```
After this commit:
```
Generated Stylo bindings in: Duration { secs: 3, nanos: 548797242 }
```
So it appears to be about 20ms slower at generating Stylo bindings, but I
suspect this is well within the noise.
Finally, this also lets us remove that nasty `mem::transmute` inside
`bindgen::ir::BindgenContext::gen` that was used for the old `syntex`
context. Now `BindgenContext` doesn't have a lifetime parameter either. This
should make it easier to revisit doing our analyses in parallel with `rayon`,
since that context was one of the things that made it hard for `BindgenContext`
to implement `Sync`.
Fixes #925
Diffstat (limited to 'tests/headers/nsBaseHashtable.hpp')
-rw-r--r-- | tests/headers/nsBaseHashtable.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/headers/nsBaseHashtable.hpp b/tests/headers/nsBaseHashtable.hpp new file mode 100644 index 00000000..36a480f2 --- /dev/null +++ b/tests/headers/nsBaseHashtable.hpp @@ -0,0 +1,48 @@ +// bindgen-flags: -- -std=c++14 + +using uint32_t = unsigned long; +using size_t = unsigned long long; + +template<class KeyClass, class DataType> +class nsBaseHashtableET { +}; + +template<class Entry> +class nsTHashtable { +}; + +template<class KeyClass, class DataType, class UserDataType> +class nsBaseHashtable + : protected nsTHashtable<nsBaseHashtableET<KeyClass, DataType>> +{ + +public: + typedef typename KeyClass::KeyType KeyType; + typedef nsBaseHashtableET<KeyClass, DataType> EntryType; + + using nsTHashtable<EntryType>::Contains; + using nsTHashtable<EntryType>::GetGeneration; + + nsBaseHashtable() {} + explicit nsBaseHashtable(uint32_t); + + struct LookupResult { + private: + EntryType* mEntry; + nsBaseHashtable& mTable; + + public: + LookupResult(EntryType*, nsBaseHashtable&); + }; + + struct EntryPtr { + private: + EntryType& mEntry; + bool mExistingEntry; + + public: + EntryPtr(nsBaseHashtable&, EntryType*, bool); + ~EntryPtr(); + }; + +}; |