From 54c1972fc4aee71080d0a8f24f6c4c1ea58069a0 Mon Sep 17 00:00:00 2001 From: ntrifunovic Date: Sat, 12 Nov 2011 17:12:34 +0000 Subject: [PATCH] Changed validate_next to take a reference instead of pointer. Resulted in 5% performance improvement. git-svn-id: http://svn.code.sf.net/p/utfcpp/code@129 a809a056-fc17-0410-9590-b4f493f8b08e --- source/utf8/checked.h | 2 +- source/utf8/core.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/utf8/checked.h b/source/utf8/checked.h index a225660..8c59c83 100644 --- a/source/utf8/checked.h +++ b/source/utf8/checked.h @@ -137,7 +137,7 @@ namespace utf8 uint32_t next(octet_iterator& it, octet_iterator end) { uint32_t cp = 0; - internal::utf_error err_code = utf8::internal::validate_next(it, end, &cp); + internal::utf_error err_code = utf8::internal::validate_next(it, end, cp); switch (err_code) { case internal::UTF8_OK : break; diff --git a/source/utf8/core.h b/source/utf8/core.h index 889cdec..693d388 100644 --- a/source/utf8/core.h +++ b/source/utf8/core.h @@ -220,7 +220,7 @@ namespace internal #undef UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR template - utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t* code_point) + utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point) { // Save the original value of it so we can go back in case of failure // Of course, it does not make much sense with i.e. stream iterators @@ -255,8 +255,7 @@ namespace internal if (utf8::internal::is_code_point_valid(cp)) { if (!utf8::internal::is_overlong_sequence(cp, length)){ // Passed! Return here. - if (code_point) - *code_point = cp; + code_point = cp; ++it; return UTF8_OK; } @@ -274,7 +273,8 @@ namespace internal template inline utf_error validate_next(octet_iterator& it, octet_iterator end) { - return utf8::internal::validate_next(it, end, 0); + uint32_t ignored; + return utf8::internal::validate_next(it, end, ignored); } } // namespace internal