Skip to content
Merged
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
13 changes: 7 additions & 6 deletions std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ struct FormatSpec(Char)
if (is(Unqual!Char == Char))
{
import std.ascii : isDigit;
import std.algorithm : startsWith;
import std.algorithm.searching : startsWith;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not move this to top, ie alphabetize, as long as you're changing it?

import std.conv : parse, text, to;

/**
Expand Down Expand Up @@ -1672,7 +1672,8 @@ Params:
void formatValue(Writer, T, Char)(Writer w, T obj, ref FormatSpec!Char f)
if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
{
import std.algorithm : find, min;
import std.algorithm.searching : find;
import std.algorithm.comparison : min;
Copy link
Contributor

Choose a reason for hiding this comment

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

Comparison before searching, alphabetize.

FormatSpec!Char fs = f; // fs is copy for change its values.
FloatingPointTypeOf!T val = obj;

Expand Down Expand Up @@ -4293,7 +4294,7 @@ private template acceptedSpecs(T)
T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec)
if (isInputRange!Range && is(Unqual!T == bool))
{
import std.algorithm : find;
import std.algorithm.searching : find;
import std.conv : parse, text;
if (spec.spec == 's')
{
Expand Down Expand Up @@ -4363,7 +4364,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec)
T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec)
if (isInputRange!Range && isIntegral!T && !is(T == enum))
{
import std.algorithm : find;
import std.algorithm.searching : find;
import std.conv : parse, text;
enforce(find(acceptedSpecs!T, spec.spec).length,
text("Wrong unformat specifier '%", spec.spec , "' for ", T.stringof));
Expand All @@ -4385,7 +4386,7 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec)
T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec)
if (isFloatingPoint!T && !is(T == enum))
{
import std.algorithm : find;
import std.algorithm.searching : find;
import std.conv : parse, text;
if (spec.spec == 'r')
{
Expand Down Expand Up @@ -4467,7 +4468,7 @@ pure unittest
T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec)
if (isInputRange!Range && isSomeChar!T && !is(T == enum))
{
import std.algorithm : find;
import std.algorithm.searching : find;
import std.conv : to, text;
if (spec.spec == 's' || spec.spec == 'c')
{
Expand Down