Skip to content
Snippets Groups Projects
  1. Sep 20, 2015
    • Arseny Kapoulkine's avatar
      tests: Add tests for integer overflow during conversion · 5b86a8f6
      Arseny Kapoulkine authored
      These tests are only testing attribute as_int in hopes that xml_text uses the
      same underlying implementation (which it does).
      5b86a8f6
    • Arseny Kapoulkine's avatar
      Implement custom string to integer conversion · ec0c9c55
      Arseny Kapoulkine authored
      This makes conversion significantly faster and removes more CRT dependencies;
      in particular, to support long long pugixml only requires the type itself (and
      the division operator...).
      
      New implementation is up to 3x faster on short decimal numbers.
      
      Note that unlike the old implementation, new implementation correctly handles
      overflow and underflow and clamps the value to the representable range. This
      means that there are some behavior changes - e.g. previously as_uint on "-1"
      would return INT_MAX instead of 0.
      
      In addition to CRT issues, for platforms with 64-bit long old implementation
      incorrectly truncated from long to int or unsigned int, so even if CRT clamped
      the values the result would have been incorrect.
      ec0c9c55
    • Arseny Kapoulkine's avatar
      Remove extra const from operator= declaration · bda55c81
      Arseny Kapoulkine authored
      This does not really matter too much but it's better to be consistent.
      bda55c81
    • Arseny Kapoulkine's avatar
      Inline widen_ascii to get rid of an extra strlen call · 25cce38f
      Arseny Kapoulkine authored
      Also since this function is only used once and is not defined in regular mode
      to avoid warnings this simplifies code a bit.
      25cce38f
    • Arseny Kapoulkine's avatar
      Eliminate redundant strlen calls during set_value/set · 9c539f92
      Arseny Kapoulkine authored
      Since we use manual integer conversion we know the length of the string.
      
      This makes set_value(int) ~30% faster for 4-digit numbers.
      9c539f92
    • Arseny Kapoulkine's avatar
      Force callers of strcpy_insitu to compute string length · 5750b7cc
      Arseny Kapoulkine authored
      This makes it possible to avoid calling strlen if we already know the string
      size.
      5750b7cc
    • Arseny Kapoulkine's avatar
      Implement integer to string conversion manually · 131c1a15
      Arseny Kapoulkine authored
      This reduces the amount of non-standard C++ functionality pugixml may be using
      by avoiding sprintf with %lld; additionally this implementation is significantly
      faster (4-5x) than sprintf, mostly due to avoiding format string parsing and
      stream setup that commonly happens in CRT implementations.
      
      This comes at the expense of requiring long long division/remainder operations
      if PUGIXML_USE_LONG_LONG is defined which will surely bite me one day.
      131c1a15
  2. Sep 19, 2015
  3. Aug 25, 2015
  4. Aug 14, 2015
  5. Jul 27, 2015
    • Arseny Kapoulkine's avatar
      Fix two UB sanitizer false positives · f738675f
      Arseny Kapoulkine authored
      Change the expression to reference the array element indirectly. The memory
      block can be bigger than the structure so it's invalid to use static data[]
      size for bounds checking.
      f738675f
  6. Jul 25, 2015
    • Arseny Kapoulkine's avatar
      XPath: Increase memory block alignment to 8 bytes · bd7a8fa4
      Arseny Kapoulkine authored
      To be more precise, the memory block is now aligned to be able to reliably
      allocate objects with both double and pointer fields. If there is a platform
      with a 4-byte double and a 4-byte pointer, the memory block alignment there will
      stay the same after this change.
      
      Fixes #48.
      bd7a8fa4
    • Arseny Kapoulkine's avatar
      tests: Fix test allocator to provide fundamental alignment · e8fdd130
      Arseny Kapoulkine authored
      Previously test allocator only guaranteed alignment enough for a pointer.
      
      On some platforms (e.g. SPARC) double has to be aligned to 8 bytes but pointers
      can have a size of 4 bytes. This commit increases allocation header to fix that.
      
      In practical terms the allocation header is now always 8 bytes.
      e8fdd130
    • Arseny Kapoulkine's avatar
      XPath: Refactor block allocation · 66f242a4
      Arseny Kapoulkine authored
      Extract memory page size and block alignment into named constants.
      66f242a4
    • Arseny Kapoulkine's avatar
      tests: Only enable page heap on x86/x64 · a562bf6d
      Arseny Kapoulkine authored
      This fixes tests in PUGIXML_NO_XPATH mode on SPARC64 (#48).
      
      SPARC does not allow unaligned accesses - e.g. you can't read an unaligned int.
      Normally pugixml does not perform unaligned integer/pointer accesses, but page
      heap can allocate blocks that are not aligned so that we can detect a single-
      byte read/write overrun.
      
      Additionally, the hardcoded page size we're currently using is really system
      specific - on SPARC the page size can be 8 Kb instead of 4 Kb so mprotect can
      fail.
      a562bf6d
  7. Jul 23, 2015
  8. Jun 24, 2015
  9. Jun 13, 2015
    • Arseny Kapoulkine's avatar
      Makefile now supports Xcode 7 ASAN · 238b786b
      Arseny Kapoulkine authored
      All other sanitizers are still unavailable so only enable them on non-OSX
      systems.
      238b786b
    • Arseny Kapoulkine's avatar
      Fix Clang 3.7 compatibility · d04df2a4
      Arseny Kapoulkine authored
      Apparently Clang 3.7 implements C++ DR 1748 that makes placement new with null
      pointer undefined behavior. Which renders all C++ programs that rely on this
      invalid. Which includes pugixml.
      
      This is not very likely to happen in the wild because the allocations that are
      subject to this in pugixml are relatively small, but tests break because of
      this.
      
      Fix the issue by adding null pointer checks (that are completely redundant in
      all current compilers except Clang 3.7 but it's not like there is another
      option).
      d04df2a4
  10. May 23, 2015
  11. May 22, 2015
  12. May 20, 2015
  13. May 14, 2015
    • Arseny Kapoulkine's avatar
      Implement xml_node::attribute with a hint · f828eae3
      Arseny Kapoulkine authored
      Extra argument 'hint' is used to start the attribute lookup; if the attribute
      is not found the lookup is restarted from the beginning of the attriubte list.
      
      This allows to optimize attribute lookups if you need to get many attributes
      from the node and can make assumptions about the likely ordering. The code is
      correct regardless of the order, but it is faster than using vanilla lookups
      if the order matches the calling order.
      
      Fixes #30.
      f828eae3
  14. May 13, 2015
  15. May 04, 2015
Loading