Use folly's split instead of custom split in day2
parent
b83b0a098b
commit
05237669a0
|
@ -0,0 +1,15 @@
|
|||
CC=g++
|
||||
BIN_NAME=day2
|
||||
CCFLAGS=-o $(BIN_NAME)
|
||||
LDFLAGS=-lfolly
|
||||
|
||||
.PHONY: all, clean
|
||||
|
||||
all: $(BIN_NAME)
|
||||
|
||||
clean:
|
||||
rm -f $(BIN_NAME)
|
||||
|
||||
$(BIN_NAME):
|
||||
$(CC) $(CCFLAGS) $(LDFLAGS) day2.cpp
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
#include <folly/String.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
|
@ -75,8 +77,10 @@ class Entry {
|
|||
*/
|
||||
static Entry parse(const std::string &input) {
|
||||
int delimIndex = input.find(DELIM);
|
||||
std::string rawPolicy = input.substr(0, delimIndex);
|
||||
std::string password = input.substr(delimIndex + DELIM.length());
|
||||
std::vector<std::string> components;
|
||||
folly::split(DELIM, input, components);
|
||||
std::string rawPolicy = components.at(0);
|
||||
std::string password = components.at(1);
|
||||
Policy policy = Policy::parse(rawPolicy);
|
||||
|
||||
return Entry(policy, password);
|
||||
|
|
Loading…
Reference in New Issue