1. 05 Aug, 2018 5 commits
    • Kenton Varda's avatar
    • Kenton Varda's avatar
      7f04f657
    • Kenton Varda's avatar
      Sadly, MSVC cannot handle pointer-to-members in constexprs. · 5cd3e108
      Kenton Varda authored
      This is true even if the pointer-to-member is never actually used, but only has its type matched, which was what kj::size() was trying to do.
      
      Oh well, define some damned constants instead.
      5cd3e108
    • Kenton Varda's avatar
      Implement kj::Table, an alternative to STL maps/sets. · 8707e731
      Kenton Varda authored
      Hash-based (unordered) and tree-based (ordered) indexing are provided.
      
      kj::Table offers advantages over STL:
      - A Table can have multiple indexes (allowing lookup by multiple keys). Different indexes can use different algorithms (e.g. hash vs. tree) and have different uniqueness constraints.
      - The properties on which a Table is indexed need not be explicit fields -- they can be computed from the table's row type.
      - Tables use less memory and make fewer allocations than STL, because rows are stored in a contiguous array.
      - The hash indexing implementation uses linear probing rather than chaining, which again means far fewer allocations and more cache-friendliness.
      - The tree indexing implementation uses B-trees optimized for cache line size, whereas STL uses cache-unfriendly and allocation-heavy red-black binary trees. (However, STL trees are overall more cache-friendly; see below.)
      - Most of the b-tree implementation is not templated. This reduces code bloat, at the cost of some performance due to virtual calls.
      
      On an ad hoc benchmark on large tables, the hash index implementation appears to outperform libc++'s `std::unordered_set` by ~60%. However, libc++'s `std::set` still outperforms the B-tree index by ~70%. It looks like the B-tree implementation suffers in part from the fact that keys are not stored inline in the tree nodes, forcing extra memory indirections. This is a price we pay for lower memory usage overall, and the ability to have multiple indexes on one table. The b-tree implementation also suffers somewhat from not being 100% templates, compared to STL, but I think this is a reasonable trade-off. The most performance-critical use cases will use hash indexes anyway.
      8707e731
    • Kenton Varda's avatar
      We now require C++14. · 66730ef6
      Kenton Varda authored
      I'm tired of working around missing features that were added in C++14. It's four years old now, compilers should support it.
      66730ef6
  2. 15 Jul, 2018 1 commit
  3. 31 Jan, 2018 1 commit
    • Kenton Varda's avatar
      Add Array::attach() and ArrayPtr::attach(). · 8447ac76
      Kenton Varda authored
      Array::attach() is like Own::attach().
      
      ArrayPtr::attach() promotes an ArrayPtr to an Array by attaching other objects to it. (Hopefully one of those objects actually owns the underlying array data.)
      8447ac76
  4. 11 Jan, 2018 1 commit
    • Kenton Varda's avatar
      Replace all include guards with #pragma once. · 677a52ab
      Kenton Varda authored
      @kloepper pointed out a while back that every compiler you've ever heard of supports this. Plus, it's more concise, it's not prone to copy-paste errors, and it looks nicer.
      
      At the time I wanted to remain consistent and I didn't feel like spending the time to update all my existing code. But, every time I've added a new header since I've cursed the include guard, so I finally broke down and changed it.
      677a52ab
  5. 10 Nov, 2017 1 commit
  6. 12 Oct, 2017 1 commit
  7. 21 Sep, 2017 1 commit
  8. 19 Sep, 2017 1 commit
  9. 12 Sep, 2017 1 commit
    • Kenton Varda's avatar
      Implement _kj suffix for string literals. · 8777008e
      Kenton Varda authored
      E.g.:
      
          "foo"_kj
      
      This literal will have type StringPtr. Although any string literal can implicitly cast to StringPtr, using the _kj suffix has the advantage that it can be constexpr.
      8777008e
  10. 27 Jun, 2017 1 commit
  11. 01 Jun, 2017 1 commit
  12. 23 May, 2017 1 commit
    • Kenton Varda's avatar
      Improve KJ encoding lib error handling: · df52bf86
      Kenton Varda authored
      - Rename UtfResult -> EncodingResult
      - Make it usable like a Maybe, so that we don't need separate "try" functions.
      - Check errors in hex decoding and URI decoding.
      df52bf86
  13. 22 May, 2017 1 commit
    • Kenton Varda's avatar
      Disable implicit conversion from string literal to ArrayPtr<const char>. · 97aae1bb
      Kenton Varda authored
      This conversion would end up including the NUL terminator in the array, which is almost never what you want.
      
      We can perhaps re-enable this in the future and have it automatically remove the NUL terminator, but we should do at least one release with it disabled to catch anyone who might be affected by the change in behavior.
      97aae1bb
  14. 05 May, 2017 1 commit
  15. 29 Apr, 2017 2 commits
  16. 25 Apr, 2017 1 commit
  17. 11 Apr, 2017 1 commit
  18. 10 Apr, 2017 1 commit
  19. 07 Apr, 2017 3 commits
  20. 30 Mar, 2017 2 commits
  21. 29 Mar, 2017 1 commit
  22. 24 Mar, 2017 2 commits
  23. 24 Jan, 2017 3 commits
  24. 15 Nov, 2016 1 commit
  25. 13 Jun, 2016 1 commit
  26. 20 May, 2016 2 commits
  27. 02 May, 2016 1 commit
  28. 06 Apr, 2016 1 commit