tools/jprof/strset.cpp
author Daisuke Akatsuka <daisuke@birchill.co.jp>
Wed, 14 Apr 2021 08:41:03 +0000
changeset 575849 60fe9f6a260ef93f51636527992de3d9260a4bf9
parent 448966 6f3709b3878117466168c40affa7bca0b60cf75b
permissions -rw-r--r--
Bug 1704073: Make the contrast of placeholders and labels on searchbar stronger.r=mak Since the opacity is not 0 for placeholder originaly[1], just changing the color does not make the same color as figma, we set the opacity as well. [1] https://searchfox.org/mozilla-central/rev/d9f6cded535d202a9ade4a530e653e659bcb5bbd/layout/style/res/forms.css#214 Differential Revision: https://phabricator.services.mozilla.com/D111784

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "strset.h"
#include <malloc.h>
#include <string.h>

StrSet::StrSet() {
  strings = 0;
  numstrings = 0;
}

void StrSet::add(const char* s) {
  if (strings) {
    strings = (char**)realloc(strings, (numstrings + 1) * sizeof(char*));
  } else {
    strings = (char**)malloc(sizeof(char*));
  }
  strings[numstrings] = strdup(s);
  numstrings++;
}

int StrSet::contains(const char* s) {
  char** sp = strings;
  int i = numstrings;

  while (--i >= 0) {
    char* ss = *sp++;
    if (ss[0] == s[0]) {
      if (strcmp(ss, s) == 0) {
        return 1;
      }
    }
  }
  return 0;
}