Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ bool operator==(Struct const& lhs, Struct const& rhs);

struct ColumnData {
std::string value;
// TODO(#14387): Use absl::optional instead.
// TODO(#14387): Use std::optional instead.
bool is_null{false};
std::string DebugString(absl::string_view name,
TracingOptions const& options = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <optional>
#include <string>

namespace google {
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/v2/minimal/internal/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <nlohmann/json.hpp>
#include <optional>
#include <string>

namespace google {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <nlohmann/json.hpp>
#include <chrono>
#include <optional>
#include <string>

namespace google {
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/bigquery/v2/minimal/internal/job_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <nlohmann/json.hpp>
#include <chrono>
#include <optional>
#include <ostream>
#include <string>

Expand Down Expand Up @@ -114,11 +114,11 @@ class ListJobsRequest {
std::string const& project_id() const { return project_id_; }
bool const& all_users() const { return all_users_; }
std::int32_t const& max_results() const { return max_results_; }
absl::optional<std::chrono::system_clock::time_point> const&
std::optional<std::chrono::system_clock::time_point> const&
min_creation_time() const {
return min_creation_time_;
}
absl::optional<std::chrono::system_clock::time_point> const&
std::optional<std::chrono::system_clock::time_point> const&
max_creation_time() const {
return max_creation_time_;
}
Comment on lines +117 to 124

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since std::chrono::system_clock::time_point is a small, trivially copyable type, std::optional<std::chrono::system_clock::time_point> is also small and cheap to copy. Returning it by value instead of by const& is more idiomatic in C++, avoids pointer indirection overhead, and prevents potential lifetime issues (dangling references) for callers.

  std::optional<std::chrono::system_clock::time_point>
  min_creation_time() const {
    return min_creation_time_;
  }
  std::optional<std::chrono::system_clock::time_point>
  max_creation_time() const {
    return max_creation_time_;
  }

Expand Down Expand Up @@ -211,8 +211,8 @@ class ListJobsRequest {
std::string project_id_;
bool all_users_;
std::int32_t max_results_;
absl::optional<std::chrono::system_clock::time_point> min_creation_time_;
absl::optional<std::chrono::system_clock::time_point> max_creation_time_;
std::optional<std::chrono::system_clock::time_point> min_creation_time_;
std::optional<std::chrono::system_clock::time_point> max_creation_time_;
std::string page_token_;
Projection projection_;
StateFilter state_filter_;
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/v2/minimal/internal/job_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <nlohmann/json.hpp>
#include <chrono>
#include <optional>
#include <string>

namespace google {
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/v2/minimal/internal/project.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <nlohmann/json.hpp>
#include <optional>
#include <string>

namespace google {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <optional>
#include <string>

namespace google {
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/v2/minimal/internal/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <nlohmann/json.hpp>
#include <chrono>
#include <optional>
#include <string>

namespace google {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "google/cloud/tracing_options.h"
#include "google/cloud/version.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include <optional>
#include <string>

namespace google {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ QueryRequest MakeQueryRequest() {
.set_create_session(true)
.set_max_results(10)
.set_maximum_bytes_billed(100000)
.set_timeout(std::chrono ::milliseconds(10));
.set_timeout(std::chrono::milliseconds(10));

std::vector<ConnectionProperty> props;
props.push_back(MakeConnectionProperty());
Expand Down
Loading