[code health] Prefer Optional<>::value() to operator*()
Improves readability especially when the underlying type has its own
operator*() method. Rely on built-in operator==() between optional and
underlying type to avoid some calls to value(), but stop short of doing
the same for `>` and `<' comparisons.
Change-Id: I207c79c04e3f4013f07a423decb250a826261cb8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/81352
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 8327dc3..ee148fd 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -307,9 +307,9 @@
Optional<WideString> ret =
TryVSWPrintf(static_cast<size_t>(maxLen), format, argListCopy);
va_end(argListCopy);
-
if (ret.has_value())
- return *ret;
+ return ret.value();
+
maxLen *= 2;
}
return WideString();